@descope-ui/descope-multi-select-combo-box 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/src/theme.js ADDED
@@ -0,0 +1,90 @@
1
+ import { getThemeRefs } from '@descope-ui/common/theme-helpers';
2
+
3
+ import themeGlobals from '@descope-ui/theme-globals';
4
+ import { refs } from '@descope-ui/theme-input-wrapper';
5
+
6
+ import { MultiSelectComboBoxClass } from '@descope-ui/descope-multi-select-combo-box/class';
7
+
8
+ const globalRefs = getThemeRefs(themeGlobals);
9
+ const vars = MultiSelectComboBoxClass.cssVarList;
10
+
11
+ export const multiSelectComboBox = {
12
+ [vars.hostWidth]: refs.width,
13
+ [vars.hostDirection]: refs.direction,
14
+ [vars.fontSize]: refs.fontSize,
15
+ [vars.fontFamily]: refs.fontFamily,
16
+ [vars.labelFontSize]: refs.labelFontSize,
17
+ [vars.labelFontWeight]: refs.labelFontWeight,
18
+ [vars.inputValueFontWeight]: refs.inputValueFontWeight,
19
+ [vars.inputPlaceholderFontWeight]: refs.inputPlaceholderFontWeight,
20
+ [vars.helperTextFontWeight]: refs.helperTextFontWeight,
21
+ [vars.errorMessageFontWeight]: refs.errorMessageFontWeight,
22
+ [vars.labelTextColor]: refs.labelTextColor,
23
+ [vars.errorMessageTextColor]: refs.errorMessageTextColor,
24
+ [vars.inputBorderColor]: refs.borderColor,
25
+ [vars.inputBorderWidth]: refs.borderWidth,
26
+ [vars.inputBorderStyle]: refs.borderStyle,
27
+ [vars.inputBorderRadius]: refs.borderRadius,
28
+ [vars.inputOutlineColor]: refs.outlineColor,
29
+ [vars.inputOutlineOffset]: refs.outlineOffset,
30
+ [vars.inputOutlineWidth]: refs.outlineWidth,
31
+ [vars.inputOutlineStyle]: refs.outlineStyle,
32
+ [vars.labelRequiredIndicator]: refs.requiredIndicator,
33
+ [vars.inputValueTextColor]: refs.valueTextColor,
34
+ [vars.inputPlaceholderTextColor]: refs.placeholderTextColor,
35
+ [vars.inputBackgroundColor]: refs.backgroundColor,
36
+ [vars.inputHorizontalPadding]: refs.horizontalPadding,
37
+ [vars.inputVerticalPadding]: refs.verticalPadding,
38
+ [vars.inputHeight]: refs.inputHeight,
39
+ [vars.inputDropdownButtonColor]: globalRefs.colors.surface.dark,
40
+ [vars.inputDropdownButtonCursor]: 'pointer',
41
+ [vars.inputDropdownButtonSize]: refs.toggleButtonSize,
42
+ [vars.inputDropdownButtonOffset]: globalRefs.spacing.xs,
43
+ [vars.overlayItemPaddingInlineStart]: globalRefs.spacing.xs,
44
+ [vars.overlayItemPaddingInlineEnd]: globalRefs.spacing.lg,
45
+ [vars.chipFontSize]: refs.chipFontSize,
46
+ [vars.chipTextColor]: globalRefs.colors.surface.contrast,
47
+ [vars.chipBackgroundColor]: globalRefs.colors.surface.light,
48
+ [vars.labelPosition]: refs.labelPosition,
49
+ [vars.labelTopPosition]: refs.labelTopPosition,
50
+ [vars.labelLeftPosition]: refs.labelLeftPosition,
51
+ [vars.labelHorizontalPosition]: refs.labelHorizontalPosition,
52
+ [vars.inputTransformY]: refs.inputTransformY,
53
+ [vars.inputTransition]: refs.inputTransition,
54
+ [vars.marginInlineStart]: refs.marginInlineStart,
55
+ [vars.placeholderOpacity]: refs.placeholderOpacity,
56
+ [vars.inputVerticalAlignment]: refs.inputVerticalAlignment,
57
+
58
+ [vars.errorMessageIcon]: refs.errorMessageIcon,
59
+ [vars.errorMessageIconSize]: refs.errorMessageIconSize,
60
+ [vars.errorMessageIconPadding]: refs.errorMessageIconPadding,
61
+ [vars.errorMessageIconRepeat]: refs.errorMessageIconRepeat,
62
+ [vars.errorMessageIconPosition]: refs.errorMessageIconPosition,
63
+ [vars.errorMessageFontSize]: refs.errorMessageFontSize,
64
+
65
+ labelType: {
66
+ floating: {
67
+ [vars.inputHorizontalPadding]: '0.25em',
68
+ _hasValue: {
69
+ [vars.inputHorizontalPadding]: '0.45em',
70
+ },
71
+ },
72
+ },
73
+
74
+ _readonly: {
75
+ [vars.inputDropdownButtonCursor]: 'default',
76
+ },
77
+
78
+ [vars.overlayFontSize]: refs.fontSize,
79
+ [vars.overlayFontFamily]: refs.fontFamily,
80
+ [vars.overlayCursor]: 'pointer',
81
+ [vars.overlayItemBoxShadow]: 'none',
82
+ [vars.overlayBackground]: refs.backgroundColor,
83
+ [vars.overlayTextColor]: refs.valueTextColor,
84
+
85
+ [vars.overlay.minHeight]: '400px',
86
+ [vars.overlay.margin]: '0',
87
+ };
88
+
89
+ export default multiSelectComboBox;
90
+ export { vars };
@@ -0,0 +1,192 @@
1
+ import { componentName } from '../src/component';
2
+ import {
3
+ toggleDefaultErrorMessageValueMissingDecorator,
4
+ withForm,
5
+ } from '@descope-ui/common/sb-helpers';
6
+ import {
7
+ labelControl,
8
+ placeholderControl,
9
+ sizeControl,
10
+ fullWidthControl,
11
+ directionControl,
12
+ disabledControl,
13
+ minItemsSelectionControl,
14
+ maxItemsSelectionControl,
15
+ readOnlyControl,
16
+ requiredControl,
17
+ borderedControl,
18
+ errorMissingValueControl,
19
+ overrideRenderItemControl,
20
+ itemsSourceControl,
21
+ inputLabelTypeControl,
22
+ errorPatternMismatchControl,
23
+ errorMessageIconControl,
24
+ errorMessageIconAttrs,
25
+ defaultValueMissingControl,
26
+ } from '@descope-ui/common/sb-controls';
27
+
28
+ const altRenderItem = ({ displayName, label, value }) =>
29
+ `<span data-name="${displayName}" data-id="${value}">${label}</span>`;
30
+
31
+ const Template = ({
32
+ 'allow-custom-value': allowCustomValue,
33
+ label,
34
+ placeholder,
35
+ size,
36
+ bordered,
37
+ 'full-width': fullWidth,
38
+ readonly,
39
+ required,
40
+ direction,
41
+ disabled,
42
+ data,
43
+ itemsSource,
44
+ minItemsSelection,
45
+ maxItemsSelection,
46
+ pattern,
47
+ 'default-values': defaultValues,
48
+ 'data-errormessage-value-missing': customErrorMissingValue,
49
+ 'data-errormessage-pattern-mismatch': customErrorPatternMismatch,
50
+ 'ignore-data': ignoreData,
51
+ 'label-type': labelType,
52
+ errorMsgIcon,
53
+ }) => {
54
+ let serializedData;
55
+ let serializedDefaultValues;
56
+
57
+ try {
58
+ serializedData = JSON.stringify(data);
59
+ serializedDefaultValues = JSON.stringify(defaultValues);
60
+ } catch {
61
+ // do nothing
62
+ }
63
+
64
+ if (ignoreData) {
65
+ serializedData = '[]';
66
+ }
67
+
68
+ return `
69
+ <descope-multi-select-combo-box
70
+ clear-button-visible
71
+ data='${(itemsSource === 'attr' && serializedData) || ''}'
72
+ size="${size}"
73
+ bordered="${bordered}"
74
+ item-label-path="data-name"
75
+ item-value-path="data-id"
76
+ label="${label || ''}"
77
+ placeholder="${placeholder || ''}"
78
+ default-values='${serializedDefaultValues || ''}'
79
+ required="${required || false}"
80
+ full-width="${fullWidth || false}"
81
+ readonly="${readonly || false}"
82
+ disabled="${disabled || false}"
83
+ data-errormessage-value-missing="${customErrorMissingValue || ''}"
84
+ data-errormessage-pattern-mismatch="${customErrorPatternMismatch || ''}"
85
+ st-host-direction="${direction ?? ''}"
86
+ allow-custom-value="${allowCustomValue || false}"
87
+ min-items-selection="${minItemsSelection || ''}"
88
+ max-items-selection="${maxItemsSelection || ''}"
89
+ label-type="${labelType || ''}"
90
+ pattern="${pattern || ''}"
91
+ ${errorMsgIcon ? errorMessageIconAttrs : ''}
92
+ >
93
+ ${
94
+ itemsSource === 'children'
95
+ ? `
96
+ <span data-name="ItemName1" data-id="itemId1">Trojan War Heroes' Valor</span>
97
+ <span data-name="ItemName2" data-id="itemId2">Achilles' Fateful Wrath</span>
98
+ <span data-name="ItemName3" data-id="itemId3">Epic Battle of Gods</span>
99
+ <span data-name="ItemName4" data-id="itemId4">Hector's Brave Sacrifice</span>
100
+ <span data-name="ItemName5" data-id="itemId5">Trojan Horse Deception</span>
101
+ <span data-name="ItemName6" data-id="itemId6">Agamemnon's Royal Command</span>
102
+ <span data-name="ItemName7" data-id="itemId7">Odysseus' Cunning Strategy</span>
103
+ <span data-name="ItemName8" data-id="itemId8">Helen's Beauty's Curse</span>
104
+ <span data-name="ItemName9" data-id="itemId9">Achilles' Heel Weakness</span>
105
+ <span data-name="ItemName10" data-id="itemId10">Epic Poem of Ancient</span>
106
+ `
107
+ : ''
108
+ }
109
+ </descope-multi-select-combo-box>
110
+ `;
111
+ };
112
+
113
+ const allowCustomValueControl = {
114
+ 'allow-custom-value': {
115
+ name: 'Allow Custom Values',
116
+ control: { type: 'boolean' },
117
+ },
118
+ };
119
+
120
+ export default {
121
+ component: componentName,
122
+ title: 'descope-multi-select-combo-box',
123
+ decorators: [
124
+ (story, { args }) => {
125
+ setTimeout(() => {
126
+ const element = document.querySelector(
127
+ 'descope-multi-select-combo-box',
128
+ );
129
+ if (!element) {
130
+ return;
131
+ }
132
+
133
+ if (args.itemsSource === 'prop') {
134
+ element.data = args.data;
135
+ }
136
+
137
+ if (args.overrideRenderItem) {
138
+ element.renderItem = altRenderItem;
139
+ }
140
+ });
141
+ return story();
142
+ },
143
+ toggleDefaultErrorMessageValueMissingDecorator,
144
+ withForm,
145
+ ],
146
+ argTypes: {
147
+ ...labelControl,
148
+ ...placeholderControl,
149
+ ...inputLabelTypeControl,
150
+ ...sizeControl,
151
+ ...fullWidthControl,
152
+ ...disabledControl,
153
+ ...readOnlyControl,
154
+ ...requiredControl,
155
+ ...borderedControl,
156
+ ...errorMissingValueControl,
157
+ ...errorPatternMismatchControl,
158
+ ...overrideRenderItemControl,
159
+ ...itemsSourceControl,
160
+ ...allowCustomValueControl,
161
+ ...minItemsSelectionControl,
162
+ ...maxItemsSelectionControl,
163
+ ...directionControl,
164
+ ...errorMessageIconControl,
165
+ ...defaultValueMissingControl,
166
+ 'default-values': {
167
+ name: 'Default Values',
168
+ control: { type: 'object' },
169
+ },
170
+ 'ignore-data': {
171
+ name: 'Ignore Data Value',
172
+ control: { type: 'boolean' },
173
+ },
174
+ },
175
+ };
176
+
177
+ export const Default = Template.bind({});
178
+
179
+ Default.args = {
180
+ size: 'md',
181
+ bordered: true,
182
+ itemsSource: 'children',
183
+ data: [
184
+ { displayName: 'Item1', value: '1', label: 'data item 1' },
185
+ { displayName: 'Item2', value: 'itemId2', label: 'data item 2' },
186
+ { displayName: 'Item3', value: '3', label: 'data item 3' },
187
+ { displayName: 'Item4', value: '4', label: 'data item 4' },
188
+ ],
189
+ pattern: '',
190
+ 'data-errormessage-value-missing': 'Please fill out this field.',
191
+ 'data-errormessage-pattern-mismatch': 'Please match the requested format.',
192
+ };