@descope/web-components-ui 3.5.1 → 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,169 @@
|
|
|
1
|
+
import { componentName } from '../src/components/descope-date-field';
|
|
2
|
+
import {
|
|
3
|
+
labelControl,
|
|
4
|
+
placeholderControl,
|
|
5
|
+
sizeControl,
|
|
6
|
+
fullWidthControl,
|
|
7
|
+
directionControl,
|
|
8
|
+
disabledControl,
|
|
9
|
+
readOnlyControl,
|
|
10
|
+
requiredControl,
|
|
11
|
+
borderedControl,
|
|
12
|
+
errorMissingValueControl,
|
|
13
|
+
inputLabelTypeControl,
|
|
14
|
+
errorRangeUnderflowControl,
|
|
15
|
+
errorRangeOverflowControl,
|
|
16
|
+
errorMessageIconAttrs,
|
|
17
|
+
defaultValueMissingControl,
|
|
18
|
+
defaultPatternMismatchControl,
|
|
19
|
+
} from './commonControls';
|
|
20
|
+
import {
|
|
21
|
+
toggleDefaultErrorMessageValueMissingDecorator,
|
|
22
|
+
toggleDefaultErrorMessagePatternMismatchDecorator,
|
|
23
|
+
} from './helpers';
|
|
24
|
+
|
|
25
|
+
const Template = ({
|
|
26
|
+
label,
|
|
27
|
+
placeholder,
|
|
28
|
+
size,
|
|
29
|
+
bordered,
|
|
30
|
+
direction,
|
|
31
|
+
required,
|
|
32
|
+
disabled,
|
|
33
|
+
readonly,
|
|
34
|
+
format,
|
|
35
|
+
preview,
|
|
36
|
+
'disable-calendar': disableCalendar,
|
|
37
|
+
'years-range': yearsRange,
|
|
38
|
+
'initial-value': initialValue,
|
|
39
|
+
'initial-month': initialMonth,
|
|
40
|
+
'initial-year': initialYear,
|
|
41
|
+
'full-width': fullWidth,
|
|
42
|
+
'label-type': labelType,
|
|
43
|
+
'data-errormessage-value-missing': customErrorMessage,
|
|
44
|
+
'data-errormessage-pattern-mismatch': customErrorMessagePatternMismatch,
|
|
45
|
+
'data-errormessage-range-underflow': customErrorRangeUnderflowMessage,
|
|
46
|
+
'data-errormessage-range-overflow': customErrorRangeOverflowMessage,
|
|
47
|
+
'calendar-months': dataMonths,
|
|
48
|
+
'calendar-weekdays': dataWeekdays,
|
|
49
|
+
'calendar-label-today': dataLabelToday,
|
|
50
|
+
'calendar-label-submit': dataLabelCalendarSubmit,
|
|
51
|
+
'calendar-label-cancel': dataLabelCalendarCancel,
|
|
52
|
+
'utc-time': utcTime,
|
|
53
|
+
errorMsgIcon,
|
|
54
|
+
}) => `
|
|
55
|
+
<descope-date-field
|
|
56
|
+
size="${size}"
|
|
57
|
+
bordered="${bordered}"
|
|
58
|
+
label="${label || ''}"
|
|
59
|
+
label-type="${labelType || ''}"
|
|
60
|
+
disabled="${disabled || false}"
|
|
61
|
+
placeholder="${placeholder || ''}"
|
|
62
|
+
readonly="${readonly || false}"
|
|
63
|
+
required="${required || false}"
|
|
64
|
+
full-width="${fullWidth || false}"
|
|
65
|
+
st-host-direction="${direction ?? ''}"
|
|
66
|
+
format="${format || ''}"
|
|
67
|
+
initial-value="${initialValue || ''}"
|
|
68
|
+
initial-month="${initialMonth || ''}"
|
|
69
|
+
initial-year="${initialYear || ''}"
|
|
70
|
+
preview="${preview || ''}"
|
|
71
|
+
years-range="${yearsRange || ''}"
|
|
72
|
+
disable-calendar="${disableCalendar || false}"
|
|
73
|
+
calendar-months="${dataMonths || ''}"
|
|
74
|
+
calendar-weekdays="${dataWeekdays || ''}"
|
|
75
|
+
calendar-label-today="${dataLabelToday || ''}"
|
|
76
|
+
calendar-label-submit="${dataLabelCalendarSubmit || ''}"
|
|
77
|
+
calendar-label-cancel="${dataLabelCalendarCancel || ''}"
|
|
78
|
+
data-errormessage-value-missing="${customErrorMessage || ''}"
|
|
79
|
+
data-errormessage-pattern-range-underflow="${customErrorRangeUnderflowMessage || ''}"
|
|
80
|
+
data-errormessage-pattern-range-overflow="${customErrorRangeOverflowMessage || ''}"
|
|
81
|
+
utc-time="${utcTime || false}"
|
|
82
|
+
${errorMsgIcon ? errorMessageIconAttrs : ''}
|
|
83
|
+
></descope-date-field>
|
|
84
|
+
<button id="validate">Validate</button>
|
|
85
|
+
`;
|
|
86
|
+
|
|
87
|
+
export default {
|
|
88
|
+
component: componentName,
|
|
89
|
+
title: 'descope-date-field',
|
|
90
|
+
decorators: [
|
|
91
|
+
(story) => {
|
|
92
|
+
setTimeout(() => {
|
|
93
|
+
const button = document.querySelector('#validate');
|
|
94
|
+
const ele = document.querySelector('descope-date-field');
|
|
95
|
+
button.onclick = () => {
|
|
96
|
+
ele.reportValidity();
|
|
97
|
+
};
|
|
98
|
+
});
|
|
99
|
+
return story();
|
|
100
|
+
},
|
|
101
|
+
toggleDefaultErrorMessageValueMissingDecorator,
|
|
102
|
+
toggleDefaultErrorMessagePatternMismatchDecorator,
|
|
103
|
+
],
|
|
104
|
+
argTypes: {
|
|
105
|
+
...labelControl,
|
|
106
|
+
...placeholderControl,
|
|
107
|
+
...inputLabelTypeControl,
|
|
108
|
+
...sizeControl,
|
|
109
|
+
...fullWidthControl,
|
|
110
|
+
...disabledControl,
|
|
111
|
+
...readOnlyControl,
|
|
112
|
+
...requiredControl,
|
|
113
|
+
...borderedControl,
|
|
114
|
+
...errorMissingValueControl,
|
|
115
|
+
...errorRangeUnderflowControl,
|
|
116
|
+
...errorRangeOverflowControl,
|
|
117
|
+
...directionControl,
|
|
118
|
+
...defaultValueMissingControl,
|
|
119
|
+
...defaultPatternMismatchControl,
|
|
120
|
+
format: {
|
|
121
|
+
name: 'Date Format',
|
|
122
|
+
options: ['MM/DD/YYYY', 'DD/MM/YYYY', 'YYYY/MM/DD'],
|
|
123
|
+
control: { type: 'select' },
|
|
124
|
+
},
|
|
125
|
+
'initial-value': {
|
|
126
|
+
name: 'Initial Value',
|
|
127
|
+
control: { type: 'text' },
|
|
128
|
+
},
|
|
129
|
+
'initial-year': {
|
|
130
|
+
name: 'Initial Year',
|
|
131
|
+
control: { type: 'number' },
|
|
132
|
+
},
|
|
133
|
+
'initial-month': {
|
|
134
|
+
name: 'Initial Month',
|
|
135
|
+
control: { type: 'number' },
|
|
136
|
+
},
|
|
137
|
+
preview: {
|
|
138
|
+
name: 'Preview Date',
|
|
139
|
+
control: { type: 'text' },
|
|
140
|
+
},
|
|
141
|
+
'years-range': {
|
|
142
|
+
name: 'Years Range',
|
|
143
|
+
control: { type: 'text' },
|
|
144
|
+
},
|
|
145
|
+
'calendar-months': {
|
|
146
|
+
name: 'Custom Months',
|
|
147
|
+
control: { type: 'text' },
|
|
148
|
+
},
|
|
149
|
+
'calendar-weekdays': {
|
|
150
|
+
name: 'Custom Weekdays',
|
|
151
|
+
control: { type: 'text' },
|
|
152
|
+
},
|
|
153
|
+
'disable-calendar': {
|
|
154
|
+
control: { type: 'boolean' },
|
|
155
|
+
},
|
|
156
|
+
'utc-time': {
|
|
157
|
+
control: { type: 'boolean' },
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
export const Default = Template.bind({});
|
|
163
|
+
|
|
164
|
+
Default.args = {
|
|
165
|
+
bordered: true,
|
|
166
|
+
size: 'md',
|
|
167
|
+
'data-errormessage-value-missing': 'Please fill out this field.',
|
|
168
|
+
'initial-value': '',
|
|
169
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { componentName } from '../src/components/descope-divider';
|
|
2
|
+
import { directionControl, modeControl, typographyVariantControl } from './commonControls';
|
|
3
|
+
|
|
4
|
+
const Template = ({ variant, uppercase, mode, text, vertical, italic, direction }) => `
|
|
5
|
+
<descope-divider
|
|
6
|
+
variant="${variant || ''}"
|
|
7
|
+
mode="${mode || ''}"
|
|
8
|
+
uppercase="${uppercase || ''}"
|
|
9
|
+
vertical="${vertical || ''}"
|
|
10
|
+
italic="${italic || ''}"
|
|
11
|
+
st-host-direction="${direction ?? ''}"
|
|
12
|
+
>${text || ''}</descope-divider
|
|
13
|
+
`;
|
|
14
|
+
|
|
15
|
+
export default {
|
|
16
|
+
component: componentName,
|
|
17
|
+
title: 'descope-divider',
|
|
18
|
+
argTypes: {
|
|
19
|
+
...modeControl,
|
|
20
|
+
...typographyVariantControl,
|
|
21
|
+
...directionControl,
|
|
22
|
+
uppercase: {
|
|
23
|
+
name: 'Uppercase',
|
|
24
|
+
control: { type: 'boolean' },
|
|
25
|
+
},
|
|
26
|
+
vertical: {
|
|
27
|
+
name: 'Vertical',
|
|
28
|
+
control: { type: 'boolean' },
|
|
29
|
+
},
|
|
30
|
+
italic: {
|
|
31
|
+
name: 'Italic',
|
|
32
|
+
control: { type: 'boolean' },
|
|
33
|
+
},
|
|
34
|
+
text: {
|
|
35
|
+
name: 'Text',
|
|
36
|
+
control: { type: 'text' },
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const Default = Template.bind({});
|
|
42
|
+
|
|
43
|
+
Default.args = {};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { componentName } from '../src/components/descope-email-field';
|
|
2
|
+
import {
|
|
3
|
+
toggleDefaultErrorMessagePatternMismatchDecorator,
|
|
4
|
+
toggleDefaultErrorMessageValueMissingDecorator,
|
|
5
|
+
withForm,
|
|
6
|
+
} from './helpers';
|
|
7
|
+
import {
|
|
8
|
+
labelControl,
|
|
9
|
+
placeholderControl,
|
|
10
|
+
sizeControl,
|
|
11
|
+
fullWidthControl,
|
|
12
|
+
directionControl,
|
|
13
|
+
disabledControl,
|
|
14
|
+
readOnlyControl,
|
|
15
|
+
requiredControl,
|
|
16
|
+
borderedControl,
|
|
17
|
+
errorMissingValueControl,
|
|
18
|
+
errorPatternMismatchControl,
|
|
19
|
+
inputLabelTypeControl,
|
|
20
|
+
errorMessageIconControl,
|
|
21
|
+
errorMessageIconAttrs,
|
|
22
|
+
defaultValueMissingControl,
|
|
23
|
+
defaultPatternMismatchControl,
|
|
24
|
+
} from './commonControls';
|
|
25
|
+
|
|
26
|
+
const Template = ({
|
|
27
|
+
label,
|
|
28
|
+
placeholder,
|
|
29
|
+
size,
|
|
30
|
+
bordered,
|
|
31
|
+
direction,
|
|
32
|
+
disabled,
|
|
33
|
+
required,
|
|
34
|
+
'full-width': fullWidth,
|
|
35
|
+
readonly,
|
|
36
|
+
'external-input': externalInput,
|
|
37
|
+
'data-errormessage-value-missing': customErrorMissingValue,
|
|
38
|
+
'data-errormessage-pattern-mismatch': customErrorPatternMismatch,
|
|
39
|
+
'label-type': labelType,
|
|
40
|
+
errorMsgIcon,
|
|
41
|
+
}) => `
|
|
42
|
+
<descope-email-field
|
|
43
|
+
size="${size}"
|
|
44
|
+
bordered="${bordered}"
|
|
45
|
+
label="${label || ''}"
|
|
46
|
+
placeholder="${placeholder || ''}"
|
|
47
|
+
disabled="${disabled || false}"
|
|
48
|
+
required="${required || false}"
|
|
49
|
+
readonly="${readonly || false}"
|
|
50
|
+
full-width="${fullWidth || false}"
|
|
51
|
+
data-errormessage-value-missing="${customErrorMissingValue || ''}"
|
|
52
|
+
data-errormessage-pattern-mismatch="${customErrorPatternMismatch || ''}"
|
|
53
|
+
st-host-direction="${direction ?? ''}"
|
|
54
|
+
label-type="${labelType || ''}"
|
|
55
|
+
external-input="${externalInput || false}"
|
|
56
|
+
${errorMsgIcon ? errorMessageIconAttrs : ''}
|
|
57
|
+
></descope-email-field>
|
|
58
|
+
`;
|
|
59
|
+
|
|
60
|
+
export default {
|
|
61
|
+
component: componentName,
|
|
62
|
+
title: 'descope-email-field',
|
|
63
|
+
decorators: [
|
|
64
|
+
(story, { args }) => {
|
|
65
|
+
args.validateOnBlur &&
|
|
66
|
+
setTimeout(() => {
|
|
67
|
+
document.querySelector('descope-email-field').addEventListener('blur', (e) => {
|
|
68
|
+
e.target.setAttribute('invalid', 'true');
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
return story();
|
|
73
|
+
},
|
|
74
|
+
toggleDefaultErrorMessageValueMissingDecorator,
|
|
75
|
+
toggleDefaultErrorMessagePatternMismatchDecorator,
|
|
76
|
+
withForm,
|
|
77
|
+
],
|
|
78
|
+
argTypes: {
|
|
79
|
+
...labelControl,
|
|
80
|
+
...placeholderControl,
|
|
81
|
+
...inputLabelTypeControl,
|
|
82
|
+
...sizeControl,
|
|
83
|
+
...fullWidthControl,
|
|
84
|
+
...disabledControl,
|
|
85
|
+
...readOnlyControl,
|
|
86
|
+
...requiredControl,
|
|
87
|
+
...borderedControl,
|
|
88
|
+
...errorMissingValueControl,
|
|
89
|
+
...errorPatternMismatchControl,
|
|
90
|
+
...errorPatternMismatchControl,
|
|
91
|
+
...directionControl,
|
|
92
|
+
...errorMessageIconControl,
|
|
93
|
+
...defaultValueMissingControl,
|
|
94
|
+
...defaultPatternMismatchControl,
|
|
95
|
+
'external-input': {
|
|
96
|
+
control: { type: 'boolean' },
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export const Default = Template.bind({});
|
|
102
|
+
|
|
103
|
+
Default.args = {
|
|
104
|
+
size: 'md',
|
|
105
|
+
bordered: true,
|
|
106
|
+
validateOnBlur: false,
|
|
107
|
+
'data-errormessage-value-missing': 'Please fill out this field.',
|
|
108
|
+
'data-errormessage-pattern-mismatch': 'Please match the requested format.',
|
|
109
|
+
};
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { componentName } from '../src/components/descope-grid';
|
|
2
|
+
import {
|
|
3
|
+
borderedControl,
|
|
4
|
+
sizeControl,
|
|
5
|
+
overrideRenderItemControl,
|
|
6
|
+
directionControl,
|
|
7
|
+
} from './commonControls';
|
|
8
|
+
|
|
9
|
+
const userStatuses = ['active', 'disabled', 'invited'];
|
|
10
|
+
|
|
11
|
+
const xml = `
|
|
12
|
+
<Response xmlns="urn:oasis:names:tc:SAML:2.0:protocol" ID="111" InResponseTo="b6aa8" Destination="https://api.descope.org/v1/auth/saml/acs?projectId=123&tenantId=456" Version="2.0" IssueInstant="2024-09-03T08:19:40.649Z">
|
|
13
|
+
<Assertion xmlns="urn:oasis:names:tc:SAML:2.0:assertion" Version="2.0" ID="222" IssueInstant="2024-09-03T08:19:40.649Z">
|
|
14
|
+
<AttributeStatement xmlns="urn:oasis:names:tc:SAML:2.0:assertion">
|
|
15
|
+
<Attribute xmlns="urn:oasis:names:tc:SAML:2.0:assertion" FriendlyName="" Name="email" NameFormat="">
|
|
16
|
+
<AttributeValue xmlns="urn:oasis:names:tc:SAML:2.0:assertion" xsi:type="">xxx@descope.com</AttributeValue>
|
|
17
|
+
</Attribute>
|
|
18
|
+
<Attribute xmlns="urn:oasis:names:tc:SAML:2.0:assertion" FriendlyName="" Name="Groups" NameFormat="">
|
|
19
|
+
<AttributeValue xmlns="urn:oasis:names:tc:SAML:2.0:assertion" xsi:type="">aws-sandbox</AttributeValue>
|
|
20
|
+
<AttributeValue xmlns="urn:oasis:names:tc:SAML:2.0:assertion" xsi:type="">dev</AttributeValue>
|
|
21
|
+
</Attribute>
|
|
22
|
+
</AttributeStatement>
|
|
23
|
+
</Assertion>
|
|
24
|
+
</Response>
|
|
25
|
+
`;
|
|
26
|
+
|
|
27
|
+
const mockUserData = (n) =>
|
|
28
|
+
Array(n)
|
|
29
|
+
.fill()
|
|
30
|
+
.map((_, idx) => ({
|
|
31
|
+
loginId: `login${idx}@company.com`,
|
|
32
|
+
email: `email${idx}@company.com`,
|
|
33
|
+
phone: `+1-${idx}-12345`,
|
|
34
|
+
displayName: `Joe #${idx}`,
|
|
35
|
+
userTenants: [
|
|
36
|
+
{
|
|
37
|
+
tenantId: `${idx}`,
|
|
38
|
+
roleNames: ['TestRole'],
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
customAttributes: {
|
|
42
|
+
attribute1: `${idx}A`,
|
|
43
|
+
attribute2: `${idx}B`,
|
|
44
|
+
},
|
|
45
|
+
xml,
|
|
46
|
+
picture: `https://dummyimage.com/50x50/000/fff`,
|
|
47
|
+
verifiedEmail: true,
|
|
48
|
+
verifiedPhone: true,
|
|
49
|
+
test: false,
|
|
50
|
+
status: userStatuses[idx % 3],
|
|
51
|
+
}));
|
|
52
|
+
|
|
53
|
+
const altRenderColumn = ({ path, header, type, attrs = {} }) => {
|
|
54
|
+
const colAttrs = Object.entries(attrs)
|
|
55
|
+
.map((pair) => `${pair[0]}="${pair[1] || ''}"`)
|
|
56
|
+
.join(' ');
|
|
57
|
+
|
|
58
|
+
return `<descope-grid-${type}-column path="${path}" header="${header} (custom)" ${colAttrs}></descope-grid-${type}-column>`;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const columnsData = [
|
|
62
|
+
{
|
|
63
|
+
path: '',
|
|
64
|
+
header: '',
|
|
65
|
+
type: 'selection',
|
|
66
|
+
attrs: { frozen: 'true', 'auto-width': '' },
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
path: 'loginId',
|
|
70
|
+
header: 'Login ID',
|
|
71
|
+
type: 'text',
|
|
72
|
+
attrs: { resizable: '', 'auto-width': '' },
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
path: 'status',
|
|
76
|
+
header: 'Status',
|
|
77
|
+
type: 'custom',
|
|
78
|
+
attrs: { resizable: '', 'auto-width': '', status: 'Active,Inactive' },
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
path: 'displayName',
|
|
82
|
+
header: 'Name',
|
|
83
|
+
type: 'text',
|
|
84
|
+
attrs: { resizable: '', 'auto-width': '' },
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
path: 'email',
|
|
88
|
+
header: 'Email',
|
|
89
|
+
type: 'text',
|
|
90
|
+
attrs: { resizable: '', 'auto-width': '' },
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
path: 'phone',
|
|
94
|
+
header: 'Phone',
|
|
95
|
+
type: 'text',
|
|
96
|
+
attrs: { resizable: '', 'auto-width': '' },
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
path: '',
|
|
100
|
+
header: '',
|
|
101
|
+
type: 'item-details',
|
|
102
|
+
attrs: { 'frozen-to-end': 'true', 'auto-width': '' },
|
|
103
|
+
},
|
|
104
|
+
];
|
|
105
|
+
|
|
106
|
+
const Template = ({ data, bordered, size, columnsSyncProp, containerHeight, direction }) => {
|
|
107
|
+
let serializedData;
|
|
108
|
+
|
|
109
|
+
try {
|
|
110
|
+
serializedData = JSON.stringify(data);
|
|
111
|
+
} catch (e) {
|
|
112
|
+
// do nothing
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const columnsTemplate = `
|
|
116
|
+
<descope-grid-selection-column frozen auto-width></descope-grid-selection-column>
|
|
117
|
+
<descope-grid-text-column path="loginId" header="Login ID" resizable auto-width></descope-grid-text-column>
|
|
118
|
+
<descope-grid-custom-column sortable="true" path="status" header="Status" resizable>
|
|
119
|
+
<descope-badge mode="default" data-pattern="invited" bordered="true" size="xs" st-text-transform="capitalize"></descope-badge>
|
|
120
|
+
<descope-badge mode="primary" data-pattern="active" bordered="true" size="xs" st-text-transform="capitalize"></descope-badge>
|
|
121
|
+
<descope-badge mode="error" data-pattern="disabled" bordered="true" size="xs" st-text-transform="capitalize"></descope-badge>
|
|
122
|
+
</descope-grid-custom-column>
|
|
123
|
+
<descope-grid-text-column sortable="true" path="displayName" header="Name" resizable auto-width></descope-grid-text-column>
|
|
124
|
+
<descope-grid-text-column sortable="true" path="email" header="Email" resizable auto-width></descope-grid-text-column>
|
|
125
|
+
<descope-grid-text-column sortable="true" path="phone" header="Phone" resizable auto-width></descope-grid-text-column>
|
|
126
|
+
<descope-grid-item-details-column auto-width frozen-to-end></descope-grid-item-details-column>
|
|
127
|
+
`;
|
|
128
|
+
|
|
129
|
+
return `
|
|
130
|
+
<style nonce=${window.DESCOPE_NONCE}>
|
|
131
|
+
.wrapper {
|
|
132
|
+
height: ${containerHeight};
|
|
133
|
+
}
|
|
134
|
+
</style>
|
|
135
|
+
<div class="wrapper">
|
|
136
|
+
<descope-grid
|
|
137
|
+
st-host-direction="${direction ?? ''}"
|
|
138
|
+
bordered="${bordered}"
|
|
139
|
+
size="${size}"
|
|
140
|
+
columns='${columnsSyncProp === 'attribute' ? JSON.stringify(columnsData) : ''}'
|
|
141
|
+
column-reordering-allowed
|
|
142
|
+
identifier="loginId"
|
|
143
|
+
>
|
|
144
|
+
${columnsSyncProp === 'template' ? columnsTemplate : ''}
|
|
145
|
+
</descope-grid>
|
|
146
|
+
</div>
|
|
147
|
+
`;
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
export default {
|
|
151
|
+
component: componentName,
|
|
152
|
+
title: 'descope-grid',
|
|
153
|
+
decorators: [
|
|
154
|
+
(story, { args }) => {
|
|
155
|
+
const observer = new MutationObserver(() => {
|
|
156
|
+
const ele = document.querySelector('descope-grid');
|
|
157
|
+
if (!ele) return;
|
|
158
|
+
|
|
159
|
+
observer.disconnect();
|
|
160
|
+
|
|
161
|
+
if (args.overrideRenderItem) {
|
|
162
|
+
ele.renderColumn = altRenderColumn;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (args.itemsSyncProp === 'propSync') {
|
|
166
|
+
ele.data = args.data;
|
|
167
|
+
} else {
|
|
168
|
+
setTimeout(() => {
|
|
169
|
+
ele.data = args.data;
|
|
170
|
+
}, 500);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (args.columnsSyncProp === 'propSync') {
|
|
174
|
+
ele.columns = columnsData;
|
|
175
|
+
} else if (args.columnsSyncProp === 'propAsync') {
|
|
176
|
+
setTimeout(() => {
|
|
177
|
+
ele.columns = columnsData;
|
|
178
|
+
}, 500);
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
observer.observe(document.body, {
|
|
183
|
+
childList: true,
|
|
184
|
+
subtree: true,
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
return story();
|
|
188
|
+
},
|
|
189
|
+
],
|
|
190
|
+
argTypes: {
|
|
191
|
+
...sizeControl,
|
|
192
|
+
...borderedControl,
|
|
193
|
+
...overrideRenderItemControl,
|
|
194
|
+
...directionControl,
|
|
195
|
+
columnsSyncProp: {
|
|
196
|
+
name: 'Columns Source',
|
|
197
|
+
options: ['none', 'attribute', 'template', 'propSync', 'propAsync'],
|
|
198
|
+
control: { type: 'select' },
|
|
199
|
+
},
|
|
200
|
+
itemsSyncProp: {
|
|
201
|
+
name: 'Items Source',
|
|
202
|
+
options: ['propSync', 'propAsync'],
|
|
203
|
+
control: { type: 'select' },
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
export const Default = Template.bind({});
|
|
209
|
+
|
|
210
|
+
Default.args = {
|
|
211
|
+
size: 'md',
|
|
212
|
+
itemsSyncProp: 'propSync',
|
|
213
|
+
columnsSyncProp: 'template',
|
|
214
|
+
overrideRenderItem: false,
|
|
215
|
+
containerHeight: '400px',
|
|
216
|
+
bordered: true,
|
|
217
|
+
data: mockUserData(25),
|
|
218
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { componentName } from '../src/components/descope-hcaptcha';
|
|
2
|
+
import { sizeControl, directionControl } from './commonControls';
|
|
3
|
+
|
|
4
|
+
const Template = ({ size, direction }) => `
|
|
5
|
+
<descope-hcaptcha
|
|
6
|
+
size="${size}"
|
|
7
|
+
st-host-direction="${direction ?? ''}"
|
|
8
|
+
>
|
|
9
|
+
</descope-hcaptcha>
|
|
10
|
+
`;
|
|
11
|
+
|
|
12
|
+
export default {
|
|
13
|
+
component: componentName,
|
|
14
|
+
title: 'descope-hcaptcha',
|
|
15
|
+
parameters: {
|
|
16
|
+
panelPosition: 'right',
|
|
17
|
+
controls: { expanded: true },
|
|
18
|
+
},
|
|
19
|
+
argTypes: {
|
|
20
|
+
...sizeControl,
|
|
21
|
+
...directionControl,
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const Default = Template.bind({});
|
|
26
|
+
|
|
27
|
+
Default.args = {
|
|
28
|
+
size: 'md',
|
|
29
|
+
};
|