@descope-ui/descope-multi-line-mappings 3.9.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/.eslintrc.json +32 -0
- package/CHANGELOG.md +10 -0
- package/e2e/descope-multi-line-mappings.spec.ts +461 -0
- package/package.json +34 -0
- package/project.json +8 -0
- package/src/component/MultiLineMappingsClass.js +751 -0
- package/src/component/index.js +11 -0
- package/src/theme.js +24 -0
- package/stories/descope-multi-line-mappings.stories.js +174 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import '@descope-ui/descope-button';
|
|
2
|
+
import '@descope-ui/descope-multi-select-combo-box';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
componentName,
|
|
6
|
+
MultiLineMappingsClass,
|
|
7
|
+
} from './MultiLineMappingsClass';
|
|
8
|
+
|
|
9
|
+
customElements.define(componentName, MultiLineMappingsClass);
|
|
10
|
+
|
|
11
|
+
export { MultiLineMappingsClass, componentName };
|
package/src/theme.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import globals from '@descope-ui/theme-globals';
|
|
2
|
+
import { refs } from '@descope-ui/theme-input-wrapper';
|
|
3
|
+
import { MultiLineMappingsClass } from './component/MultiLineMappingsClass';
|
|
4
|
+
|
|
5
|
+
const vars = MultiLineMappingsClass.cssVarList;
|
|
6
|
+
|
|
7
|
+
const multiLineMappings = {
|
|
8
|
+
[vars.hostDirection]: refs.direction,
|
|
9
|
+
|
|
10
|
+
[vars.rowsGap]: globals.spacing.sm,
|
|
11
|
+
[vars.rowGap]: globals.spacing.sm,
|
|
12
|
+
[vars.rowAlignItems]: 'flex-end',
|
|
13
|
+
[vars.rowWrap]: 'nowrap',
|
|
14
|
+
|
|
15
|
+
[vars.addActionJustifyContent]: 'flex-start',
|
|
16
|
+
[vars.addActionMarginTop]: globals.spacing.xs,
|
|
17
|
+
|
|
18
|
+
_fullWidth: {
|
|
19
|
+
[vars.hostWidth]: '100%',
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default multiLineMappings;
|
|
24
|
+
export { vars };
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { componentName } from '../src/component';
|
|
2
|
+
import {
|
|
3
|
+
sizeControl,
|
|
4
|
+
fullWidthControl,
|
|
5
|
+
directionControl,
|
|
6
|
+
disabledControl,
|
|
7
|
+
readOnlyControl,
|
|
8
|
+
} from '@descope-ui/common/sb-controls';
|
|
9
|
+
import { withForm } from '@descope-ui/common/sb-helpers';
|
|
10
|
+
|
|
11
|
+
const DEFAULT_DATA = {
|
|
12
|
+
'tenant-a': ['viewer', 'editor', 'admin'],
|
|
13
|
+
'tenant-b': ['viewer', 'editor'],
|
|
14
|
+
'tenant-c': ['viewer', 'auditor'],
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const DEFAULT_VALUE = [
|
|
18
|
+
{
|
|
19
|
+
firstValues: 'tenant-a',
|
|
20
|
+
secondValues: ['viewer'],
|
|
21
|
+
},
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
const Template = ({
|
|
25
|
+
size,
|
|
26
|
+
disabled,
|
|
27
|
+
readonly,
|
|
28
|
+
'full-width': fullWidth,
|
|
29
|
+
direction,
|
|
30
|
+
'max-rows': maxRows,
|
|
31
|
+
'first-label': firstLabel,
|
|
32
|
+
'second-label': secondLabel,
|
|
33
|
+
'first-placeholder': firstPlaceholder,
|
|
34
|
+
'second-placeholder': secondPlaceholder,
|
|
35
|
+
'first-value-key': firstValueKey,
|
|
36
|
+
'second-value-key': secondValueKey,
|
|
37
|
+
'merge-rows': mergeRows,
|
|
38
|
+
customAddButtonContent,
|
|
39
|
+
data,
|
|
40
|
+
}) => `
|
|
41
|
+
<descope-multi-line-mappings
|
|
42
|
+
size="${size || 'md'}"
|
|
43
|
+
disabled="${disabled || false}"
|
|
44
|
+
readonly="${readonly || false}"
|
|
45
|
+
full-width="${fullWidth || false}"
|
|
46
|
+
st-host-direction="${direction || ''}"
|
|
47
|
+
max-rows="${maxRows ?? ''}"
|
|
48
|
+
first-label="${firstLabel || ''}"
|
|
49
|
+
second-label="${secondLabel || ''}"
|
|
50
|
+
first-placeholder="${firstPlaceholder || ''}"
|
|
51
|
+
second-placeholder="${secondPlaceholder || ''}"
|
|
52
|
+
first-value-key="${firstValueKey || ''}"
|
|
53
|
+
second-value-key="${secondValueKey || ''}"
|
|
54
|
+
merge-rows="${mergeRows || false}"
|
|
55
|
+
data='${JSON.stringify(data || {})}'
|
|
56
|
+
>
|
|
57
|
+
<span slot="add-button-content">${customAddButtonContent || '+ Add mapping'}</span>
|
|
58
|
+
</descope-multi-line-mappings>
|
|
59
|
+
`;
|
|
60
|
+
|
|
61
|
+
export default {
|
|
62
|
+
component: componentName,
|
|
63
|
+
title: 'descope-multi-line-mappings',
|
|
64
|
+
decorators: [
|
|
65
|
+
withForm,
|
|
66
|
+
(story, { args }) => {
|
|
67
|
+
setTimeout(() => {
|
|
68
|
+
const component = document.querySelector(componentName);
|
|
69
|
+
|
|
70
|
+
if (!component) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const firstKey = args['first-value-key'] || 'firstValues';
|
|
75
|
+
const secondKey = args['second-value-key'] || 'secondValues';
|
|
76
|
+
|
|
77
|
+
component.value = (args.value || []).map((item) => ({
|
|
78
|
+
[firstKey]: item[firstKey] ?? item.firstValues ?? '',
|
|
79
|
+
[secondKey]: item[secondKey] ?? item.secondValues ?? [],
|
|
80
|
+
}));
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
return story();
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
argTypes: {
|
|
87
|
+
...sizeControl,
|
|
88
|
+
...fullWidthControl,
|
|
89
|
+
...disabledControl,
|
|
90
|
+
...readOnlyControl,
|
|
91
|
+
...directionControl,
|
|
92
|
+
'max-rows': {
|
|
93
|
+
name: 'Max Rows',
|
|
94
|
+
control: { type: 'number' },
|
|
95
|
+
},
|
|
96
|
+
'first-label': {
|
|
97
|
+
name: 'First Combo Label',
|
|
98
|
+
control: { type: 'text' },
|
|
99
|
+
},
|
|
100
|
+
'second-label': {
|
|
101
|
+
name: 'Second Combo Label',
|
|
102
|
+
control: { type: 'text' },
|
|
103
|
+
},
|
|
104
|
+
'first-placeholder': {
|
|
105
|
+
name: 'First Combo Placeholder',
|
|
106
|
+
control: { type: 'text' },
|
|
107
|
+
},
|
|
108
|
+
'second-placeholder': {
|
|
109
|
+
name: 'Second Combo Placeholder',
|
|
110
|
+
control: { type: 'text' },
|
|
111
|
+
},
|
|
112
|
+
'first-value-key': {
|
|
113
|
+
name: 'First Value Key',
|
|
114
|
+
control: { type: 'text' },
|
|
115
|
+
},
|
|
116
|
+
'second-value-key': {
|
|
117
|
+
name: 'Second Value Key',
|
|
118
|
+
control: { type: 'text' },
|
|
119
|
+
},
|
|
120
|
+
'merge-rows': {
|
|
121
|
+
name: 'Merge Rows',
|
|
122
|
+
control: { type: 'boolean' },
|
|
123
|
+
},
|
|
124
|
+
customAddButtonContent: {
|
|
125
|
+
name: 'Custom Add slot content',
|
|
126
|
+
control: { type: 'text' },
|
|
127
|
+
},
|
|
128
|
+
data: {
|
|
129
|
+
name: 'Data',
|
|
130
|
+
control: { type: 'object' },
|
|
131
|
+
},
|
|
132
|
+
value: {
|
|
133
|
+
name: 'Component Value',
|
|
134
|
+
control: { type: 'object' },
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
export const Default = Template.bind({});
|
|
140
|
+
|
|
141
|
+
Default.args = {
|
|
142
|
+
size: 'md',
|
|
143
|
+
disabled: false,
|
|
144
|
+
readonly: false,
|
|
145
|
+
'full-width': false,
|
|
146
|
+
direction: 'ltr',
|
|
147
|
+
'max-rows': 5,
|
|
148
|
+
'first-label': 'Tenants',
|
|
149
|
+
'second-label': 'Roles',
|
|
150
|
+
'first-value-key': 'firstValues',
|
|
151
|
+
'second-value-key': 'secondValues',
|
|
152
|
+
'merge-rows': false,
|
|
153
|
+
customAddButtonContent: '+ Assign tenant/role',
|
|
154
|
+
data: DEFAULT_DATA,
|
|
155
|
+
value: DEFAULT_VALUE,
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
export const CustomKeys = Template.bind({});
|
|
159
|
+
|
|
160
|
+
CustomKeys.args = {
|
|
161
|
+
...Default.args,
|
|
162
|
+
'first-value-key': 'tenants',
|
|
163
|
+
'second-value-key': 'roles',
|
|
164
|
+
value: [
|
|
165
|
+
{
|
|
166
|
+
tenants: 'tenant-a',
|
|
167
|
+
roles: ['viewer'],
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
tenants: 'tenant-b',
|
|
171
|
+
roles: ['viewer'],
|
|
172
|
+
},
|
|
173
|
+
],
|
|
174
|
+
};
|