@descope/web-components-ui 1.0.245 → 1.0.247
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/dist/cjs/index.cjs.js +904 -674
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.esm.js +910 -677
- package/dist/index.esm.js.map +1 -1
- package/dist/umd/1000.js +1 -1
- package/dist/umd/9214.js +1 -0
- package/dist/umd/9434.js +1 -0
- package/dist/umd/button-selection-group-fields-descope-button-multi-selection-group-index-js.js +1 -0
- package/dist/umd/button-selection-group-fields-descope-button-multi-selection-group-internal-index-js.js +1 -0
- package/dist/umd/button-selection-group-fields-descope-button-selection-group-index-js.js +1 -0
- package/dist/umd/button-selection-group-fields-descope-button-selection-group-internal-index-js.js +1 -0
- package/dist/umd/button-selection-group-fields-descope-button-selection-group-item-index-js.js +1 -0
- package/dist/umd/index.js +1 -1
- package/package.json +1 -1
- package/src/components/{descope-button-selection-group/ButtonSelectionGroupClass.js → button-selection-group-fields/baseButtonSelectionGroup.js} +19 -70
- package/src/components/button-selection-group-fields/createBaseButtonSelectionGroupInternalClass.js +101 -0
- package/src/components/button-selection-group-fields/descope-button-multi-selection-group/ButtonMultiSelectionGroupClass.js +67 -0
- package/src/components/button-selection-group-fields/descope-button-multi-selection-group/index.js +7 -0
- package/src/components/button-selection-group-fields/descope-button-multi-selection-group-internal/ButtonMultiSelectionGroupInternalClass.js +106 -0
- package/src/components/button-selection-group-fields/descope-button-multi-selection-group-internal/index.js +8 -0
- package/src/components/button-selection-group-fields/descope-button-selection-group/ButtonSelectionGroupClass.js +67 -0
- package/src/components/{descope-button-selection-group → button-selection-group-fields/descope-button-selection-group}/index.js +2 -2
- package/src/components/button-selection-group-fields/descope-button-selection-group-internal/ButtonSelectionGroupInternalClass.js +77 -0
- package/src/components/descope-multi-select-combo-box/MultiSelectComboBoxClass.js +2 -2
- package/src/index.cjs.js +3 -2
- package/src/index.d.ts +2 -1
- package/src/index.js +2 -1
- package/src/mixins/inputValidationMixin.js +2 -2
- package/src/mixins/portalMixin.js +26 -15
- package/src/theme/components/buttonSelectionGroup/baseButtonSelectionGroup.js +15 -0
- package/src/theme/components/buttonSelectionGroup/buttonMultiSelectionGroup.js +11 -0
- package/src/theme/components/buttonSelectionGroup/buttonSelectionGroup.js +3 -12
- package/src/theme/components/buttonSelectionGroup/buttonSelectionGroupItem.js +1 -1
- package/src/theme/components/index.js +2 -0
- package/dist/umd/descope-button-selection-group-descope-button-selection-group-internal-index-js.js +0 -1
- package/dist/umd/descope-button-selection-group-descope-button-selection-group-item-index-js.js +0 -1
- package/dist/umd/descope-button-selection-group-index-js.js +0 -1
- package/src/components/descope-button-selection-group/descope-button-selection-group-internal/ButtonSelectionGroupInternalClass.js +0 -145
- /package/src/components/{descope-button-selection-group → button-selection-group-fields}/descope-button-selection-group-internal/index.js +0 -0
- /package/src/components/{descope-button-selection-group → button-selection-group-fields}/descope-button-selection-group-item/ButtonSelectionGroupItemClass.js +0 -0
- /package/src/components/{descope-button-selection-group → button-selection-group-fields}/descope-button-selection-group-item/index.js +0 -0
@@ -0,0 +1,67 @@
|
|
1
|
+
import {
|
2
|
+
createStyleMixin,
|
3
|
+
draggableMixin,
|
4
|
+
createProxy,
|
5
|
+
proxyInputMixin,
|
6
|
+
componentNameValidationMixin,
|
7
|
+
} from '../../../mixins';
|
8
|
+
import { componentName as descopeInternalComponentName } from '../descope-button-selection-group-internal/ButtonSelectionGroupInternalClass';
|
9
|
+
import { compose } from '../../../helpers';
|
10
|
+
import { forwardAttrs, getComponentName } from '../../../helpers/componentHelpers';
|
11
|
+
import {
|
12
|
+
buttonSelectionGroupBaseMixin,
|
13
|
+
buttonSelectionGroupMappings,
|
14
|
+
buttonSelectionGroupStyles,
|
15
|
+
} from '../baseButtonSelectionGroup';
|
16
|
+
|
17
|
+
export const componentName = getComponentName('button-selection-group');
|
18
|
+
|
19
|
+
const buttonSelectionGroupMixin = (superclass) =>
|
20
|
+
class ButtonMultiSelectionGroupMixinClass extends superclass {
|
21
|
+
init() {
|
22
|
+
super.init?.();
|
23
|
+
const template = document.createElement('template');
|
24
|
+
|
25
|
+
template.innerHTML = `
|
26
|
+
<${descopeInternalComponentName}
|
27
|
+
name="button-selection-group"
|
28
|
+
slot="input"
|
29
|
+
tabindex="-1"
|
30
|
+
part="internal-component"
|
31
|
+
>
|
32
|
+
<slot></slot>
|
33
|
+
</${descopeInternalComponentName}>
|
34
|
+
`;
|
35
|
+
|
36
|
+
this.baseElement.appendChild(template.content.cloneNode(true));
|
37
|
+
|
38
|
+
this.inputElement = this.shadowRoot.querySelector(descopeInternalComponentName);
|
39
|
+
|
40
|
+
forwardAttrs(this, this.inputElement, {
|
41
|
+
includeAttrs: ['size', 'default-value', 'allow-deselect'],
|
42
|
+
});
|
43
|
+
}
|
44
|
+
};
|
45
|
+
|
46
|
+
export const ButtonSelectionGroupClass = compose(
|
47
|
+
createStyleMixin({
|
48
|
+
mappings: {
|
49
|
+
...buttonSelectionGroupMappings,
|
50
|
+
},
|
51
|
+
}),
|
52
|
+
draggableMixin,
|
53
|
+
proxyInputMixin({ proxyProps: ['value', 'selectionStart'] }),
|
54
|
+
componentNameValidationMixin,
|
55
|
+
buttonSelectionGroupBaseMixin,
|
56
|
+
buttonSelectionGroupMixin
|
57
|
+
)(
|
58
|
+
createProxy({
|
59
|
+
slots: [],
|
60
|
+
wrappedEleName: 'vaadin-text-field',
|
61
|
+
style: () => buttonSelectionGroupStyles,
|
62
|
+
excludeAttrsSync: ['tabindex'],
|
63
|
+
componentName,
|
64
|
+
})
|
65
|
+
);
|
66
|
+
|
67
|
+
export default ButtonSelectionGroupClass;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { componentName, ButtonSelectionGroupClass } from './ButtonSelectionGroupClass';
|
2
|
-
import '
|
3
|
-
import '
|
2
|
+
import '../descope-button-selection-group-internal';
|
3
|
+
import '../descope-button-selection-group-item';
|
4
4
|
|
5
5
|
customElements.define(componentName, ButtonSelectionGroupClass);
|
6
6
|
|
@@ -0,0 +1,77 @@
|
|
1
|
+
import { getComponentName } from '../../../helpers/componentHelpers';
|
2
|
+
import { createBaseButtonSelectionGroupInternalClass } from '../createBaseButtonSelectionGroupInternalClass';
|
3
|
+
|
4
|
+
export const componentName = getComponentName('button-selection-group-internal');
|
5
|
+
|
6
|
+
export class ButtonSelectionGroupInternalClass extends createBaseButtonSelectionGroupInternalClass(
|
7
|
+
componentName
|
8
|
+
) {
|
9
|
+
getSelectedNode() {
|
10
|
+
return this.items.find((item) => item.hasAttribute('selected'));
|
11
|
+
}
|
12
|
+
|
13
|
+
get allowDeselect() {
|
14
|
+
return this.getAttribute('allow-deselect') === 'true';
|
15
|
+
}
|
16
|
+
|
17
|
+
removeSelected() {
|
18
|
+
this.getSelectedNode()?.removeAttribute('selected');
|
19
|
+
}
|
20
|
+
|
21
|
+
onClick(e) {
|
22
|
+
if (e.target !== e.currentTarget) {
|
23
|
+
if (e.target === this.getSelectedNode() && this.allowDeselect) {
|
24
|
+
this.removeSelected();
|
25
|
+
} else {
|
26
|
+
this.setSelected(e.target);
|
27
|
+
}
|
28
|
+
this.dispatchChange();
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
setSelected(node) {
|
33
|
+
if (node !== this.getSelectedNode()) {
|
34
|
+
this.removeSelected();
|
35
|
+
node?.setAttribute('selected', 'true');
|
36
|
+
}
|
37
|
+
}
|
38
|
+
|
39
|
+
get defaultValue() {
|
40
|
+
return this.getAttribute('default-value');
|
41
|
+
}
|
42
|
+
|
43
|
+
setDefaultValue() {
|
44
|
+
// we want to defer this action until all attributes are synched
|
45
|
+
setTimeout(() => {
|
46
|
+
if (this.defaultValue) {
|
47
|
+
this.value = this.defaultValue;
|
48
|
+
this.setCustomValidity();
|
49
|
+
}
|
50
|
+
});
|
51
|
+
}
|
52
|
+
|
53
|
+
get value() {
|
54
|
+
return this.getSelectedNode()?.value || '';
|
55
|
+
}
|
56
|
+
|
57
|
+
set value(value) {
|
58
|
+
const node = this.items.find((child) => child.value === value);
|
59
|
+
this.setSelected(node);
|
60
|
+
}
|
61
|
+
|
62
|
+
getValidity() {
|
63
|
+
if (this.isRequired && !this.value) {
|
64
|
+
return { valueMissing: true };
|
65
|
+
}
|
66
|
+
|
67
|
+
return {};
|
68
|
+
}
|
69
|
+
|
70
|
+
init() {
|
71
|
+
super.init();
|
72
|
+
|
73
|
+
this.setDefaultValue();
|
74
|
+
|
75
|
+
this.querySelector('slot').addEventListener('click', this.onClick.bind(this));
|
76
|
+
}
|
77
|
+
}
|
@@ -23,7 +23,7 @@ import {
|
|
23
23
|
|
24
24
|
export const componentName = getComponentName('multi-select-combo-box');
|
25
25
|
|
26
|
-
const
|
26
|
+
const multiSelectComboBoxMixin = (superclass) =>
|
27
27
|
class MultiSelectComboBoxMixinClass extends superclass {
|
28
28
|
// eslint-disable-next-line class-methods-use-this
|
29
29
|
#renderItem = ({ displayName, value, label }) => {
|
@@ -446,7 +446,7 @@ export const MultiSelectComboBoxClass = compose(
|
|
446
446
|
}),
|
447
447
|
proxyInputMixin({ proxyProps: ['selectionStart'], inputEvent: 'selected-items-changed' }),
|
448
448
|
componentNameValidationMixin,
|
449
|
-
|
449
|
+
multiSelectComboBoxMixin
|
450
450
|
)(
|
451
451
|
createProxy({
|
452
452
|
slots: ['', 'prefix'],
|
package/src/index.cjs.js
CHANGED
@@ -27,8 +27,9 @@ export { PhoneFieldInputBoxClass } from './components/phone-fields/descope-phone
|
|
27
27
|
export { NewPasswordClass } from './components/descope-new-password/NewPasswordClass';
|
28
28
|
export { RecaptchaClass } from './components/descope-recaptcha/RecaptchaClass';
|
29
29
|
export { UploadFileClass } from './components/descope-upload-file/UploadFileClass';
|
30
|
-
export { ButtonSelectionGroupClass } from './components/descope-button-selection-group/ButtonSelectionGroupClass';
|
31
|
-
export {
|
30
|
+
export { ButtonSelectionGroupClass } from './components/button-selection-group-fields/descope-button-selection-group/ButtonSelectionGroupClass';
|
31
|
+
export { ButtonMultiSelectionGroupClass } from './components/button-selection-group-fields/descope-button-multi-selection-group/ButtonMultiSelectionGroupClass';
|
32
|
+
export { ButtonSelectionGroupItemClass } from './components/button-selection-group-fields/descope-button-selection-group-item/ButtonSelectionGroupItemClass';
|
32
33
|
export { ModalClass } from './components/descope-modal/ModalClass';
|
33
34
|
export { NotificationClass } from './components/descope-notification/NotificationClass';
|
34
35
|
export { GridClass } from './components/descope-grid/GridClass';
|
package/src/index.d.ts
CHANGED
@@ -32,7 +32,8 @@ export { PhoneFieldInputBoxClass } from './components/phone-fields/descope-phone
|
|
32
32
|
export { NewPasswordClass } from './components/descope-new-password';
|
33
33
|
export { RecaptchaClass } from './components/descope-recaptcha';
|
34
34
|
export { UploadFileClass } from './components/descope-upload-file';
|
35
|
-
export { ButtonSelectionGroupClass } from './components/descope-button-selection-group/ButtonSelectionGroupClass';
|
35
|
+
export { ButtonSelectionGroupClass } from './components/button-selection-group-fields/descope-button-selection-group/ButtonSelectionGroupClass';
|
36
|
+
export { ButtonMultiSelectionGroupClass } from './components/button-selection-group-fields/descope-button-multi-selection-group/ButtonMultiSelectionGroupClass';
|
36
37
|
export { GridClass } from './components/descope-grid/GridClass';
|
37
38
|
export { GridTextColumnClass } from './components/descope-grid/descope-grid-text-column/index';
|
38
39
|
export { GridSelectionColumnClass } from './components/descope-grid/descope-grid-selection-column/index';
|
package/src/index.js
CHANGED
@@ -22,7 +22,8 @@ export * from './components/phone-fields/descope-phone-input-box-field';
|
|
22
22
|
export * from './components/descope-new-password';
|
23
23
|
export * from './components/descope-recaptcha';
|
24
24
|
export * from './components/descope-upload-file';
|
25
|
-
export * from './components/descope-button-selection-group';
|
25
|
+
export * from './components/button-selection-group-fields/descope-button-selection-group';
|
26
|
+
export * from './components/button-selection-group-fields/descope-button-multi-selection-group';
|
26
27
|
export * from './components/descope-grid';
|
27
28
|
export * from './components/descope-multi-select-combo-box';
|
28
29
|
export * from './components/descope-badge';
|
@@ -45,11 +45,11 @@ export const inputValidationMixin = (superclass) =>
|
|
45
45
|
}
|
46
46
|
|
47
47
|
get defaultErrorMsgRangeUnderflow() {
|
48
|
-
return `At least ${this.
|
48
|
+
return `At least ${this.getAttribute('min-items-selection')} items are required.`;
|
49
49
|
}
|
50
50
|
|
51
51
|
get defaultErrorMsgRangeOverflow() {
|
52
|
-
return `At most ${this.
|
52
|
+
return `At most ${this.getAttribute('max-items-selection')} items are allowed.`;
|
53
53
|
}
|
54
54
|
|
55
55
|
getErrorMessage(flags) {
|
@@ -13,10 +13,11 @@ const DISPLAY_NAME_SEPARATOR = '_';
|
|
13
13
|
|
14
14
|
const sanitizeSelector = (selector) => selector.replace(/[^\w\s]/gi, '');
|
15
15
|
|
16
|
-
const withWaitForShadowRoot = (getRootElementFn) => (that) =>
|
17
|
-
|
16
|
+
const withWaitForShadowRoot = (getRootElementFn) => async (that) => {
|
17
|
+
const ele = await getRootElementFn(that);
|
18
|
+
|
19
|
+
return new Promise((res) => {
|
18
20
|
const MAX_RETRIES = 20;
|
19
|
-
const ele = getRootElementFn(that);
|
20
21
|
let counter = 0;
|
21
22
|
|
22
23
|
const check = () => {
|
@@ -29,11 +30,12 @@ const withWaitForShadowRoot = (getRootElementFn) => (that) =>
|
|
29
30
|
|
30
31
|
counter++;
|
31
32
|
|
32
|
-
if (!ele
|
33
|
+
if (!ele?.shadowRoot) setTimeout(check);
|
33
34
|
else res(ele.shadowRoot);
|
34
35
|
};
|
35
36
|
check();
|
36
37
|
});
|
38
|
+
};
|
37
39
|
|
38
40
|
export const portalMixin =
|
39
41
|
({ name, selector, mappings = {}, forward: { attributes = [], include = true } = {} }) =>
|
@@ -59,35 +61,44 @@ export const portalMixin =
|
|
59
61
|
|
60
62
|
constructor() {
|
61
63
|
// we cannot use "this" before calling "super"
|
62
|
-
const getRootElement = (that) => {
|
64
|
+
const getRootElement = async (that) => {
|
63
65
|
const baseEle = that.shadowRoot.querySelector(that.baseSelector);
|
64
|
-
|
65
|
-
|
66
|
-
|
66
|
+
if (!selector) {
|
67
|
+
return baseEle;
|
68
|
+
}
|
69
|
+
|
70
|
+
// in case we have a selector, we should first wait for the base element shadow root
|
71
|
+
// and then look for the internal element
|
72
|
+
const baseEleShadowRoot = await withWaitForShadowRoot(() => baseEle)(that);
|
73
|
+
return baseEleShadowRoot.querySelector(selector);
|
67
74
|
};
|
68
75
|
|
76
|
+
const getPortalElement = withWaitForShadowRoot(getRootElement);
|
77
|
+
|
69
78
|
super({
|
70
|
-
getRootElement:
|
79
|
+
getRootElement: getPortalElement,
|
71
80
|
componentNameSuffix: DISPLAY_NAME_SEPARATOR + eleDisplayName,
|
72
81
|
themeSection: PORTAL_THEME_PREFIX + eleDisplayName,
|
73
82
|
baseSelector: ':host',
|
74
83
|
});
|
75
84
|
|
76
|
-
this.#portalEle =
|
85
|
+
this.#portalEle = getPortalElement(this).then((ele) => ele.host);
|
77
86
|
}
|
78
87
|
|
79
|
-
#handleHoverAttribute() {
|
80
|
-
|
88
|
+
async #handleHoverAttribute() {
|
89
|
+
const portalEle = await this.#portalEle;
|
90
|
+
portalEle.onmouseenter = (e) => {
|
81
91
|
e.target.setAttribute('hover', 'true');
|
82
92
|
};
|
83
|
-
|
93
|
+
portalEle.onmouseleave = (e) => {
|
84
94
|
e.target.removeAttribute('hover');
|
85
95
|
};
|
86
96
|
}
|
87
97
|
|
88
|
-
init() {
|
98
|
+
async init() {
|
89
99
|
super.init?.();
|
90
|
-
|
100
|
+
const portalEle = await this.#portalEle;
|
101
|
+
forwardAttrs(this, portalEle, {
|
91
102
|
[include ? 'includeAttrs' : 'excludeAttrs']: attributes,
|
92
103
|
});
|
93
104
|
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import { getThemeRefs } from '../../../helpers/themeHelpers';
|
2
|
+
import globals from '../../globals';
|
3
|
+
import { refs } from '../inputWrapper';
|
4
|
+
|
5
|
+
const globalRefs = getThemeRefs(globals);
|
6
|
+
|
7
|
+
export const createBaseButtonSelectionGroupMappings = (vars) => ({
|
8
|
+
[vars.hostDirection]: refs.direction,
|
9
|
+
[vars.fontFamily]: refs.fontFamily,
|
10
|
+
[vars.labelTextColor]: refs.labelTextColor,
|
11
|
+
[vars.labelRequiredIndicator]: refs.requiredIndicator,
|
12
|
+
[vars.errorMessageTextColor]: refs.errorMessageTextColor,
|
13
|
+
[vars.itemsSpacing]: globalRefs.spacing.sm,
|
14
|
+
[vars.hostWidth]: refs.width,
|
15
|
+
});
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { ButtonMultiSelectionGroupClass } from '../../../components/button-selection-group-fields/descope-button-multi-selection-group/ButtonMultiSelectionGroupClass';
|
2
|
+
import { createBaseButtonSelectionGroupMappings } from './baseButtonSelectionGroup';
|
3
|
+
|
4
|
+
const vars = ButtonMultiSelectionGroupClass.cssVarList;
|
5
|
+
|
6
|
+
const buttonMultiSelectionGroup = {
|
7
|
+
...createBaseButtonSelectionGroupMappings(vars),
|
8
|
+
};
|
9
|
+
|
10
|
+
export default buttonMultiSelectionGroup;
|
11
|
+
export { vars };
|
@@ -1,19 +1,10 @@
|
|
1
|
-
import { ButtonSelectionGroupClass } from '../../../components/descope-button-selection-group/ButtonSelectionGroupClass';
|
2
|
-
import {
|
3
|
-
import globals from '../../globals';
|
4
|
-
import { refs } from '../inputWrapper';
|
1
|
+
import { ButtonSelectionGroupClass } from '../../../components/button-selection-group-fields/descope-button-selection-group/ButtonSelectionGroupClass';
|
2
|
+
import { createBaseButtonSelectionGroupMappings } from './baseButtonSelectionGroup';
|
5
3
|
|
6
|
-
const globalRefs = getThemeRefs(globals);
|
7
4
|
const vars = ButtonSelectionGroupClass.cssVarList;
|
8
5
|
|
9
6
|
const buttonSelectionGroup = {
|
10
|
-
|
11
|
-
[vars.fontFamily]: refs.fontFamily,
|
12
|
-
[vars.labelTextColor]: refs.labelTextColor,
|
13
|
-
[vars.labelRequiredIndicator]: refs.requiredIndicator,
|
14
|
-
[vars.errorMessageTextColor]: refs.errorMessageTextColor,
|
15
|
-
[vars.itemsSpacing]: globalRefs.spacing.sm,
|
16
|
-
[vars.hostWidth]: refs.width,
|
7
|
+
...createBaseButtonSelectionGroupMappings(vars),
|
17
8
|
};
|
18
9
|
|
19
10
|
export default buttonSelectionGroup;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { ButtonSelectionGroupItemClass } from '../../../components/
|
1
|
+
import { ButtonSelectionGroupItemClass } from '../../../components/button-selection-group-fields/descope-button-selection-group-item/ButtonSelectionGroupItemClass';
|
2
2
|
import { getThemeRefs } from '../../../helpers/themeHelpers';
|
3
3
|
import globals from '../../globals';
|
4
4
|
|
@@ -23,6 +23,7 @@ import * as inputWrapper from './inputWrapper';
|
|
23
23
|
import * as uploadFile from './uploadFile';
|
24
24
|
import * as buttonSelectionGroupItem from './buttonSelectionGroup/buttonSelectionGroupItem';
|
25
25
|
import * as buttonSelectionGroup from './buttonSelectionGroup/buttonSelectionGroup';
|
26
|
+
import * as buttonMultiSelectionGroup from './buttonSelectionGroup/buttonMultiSelectionGroup';
|
26
27
|
import * as modal from './modal';
|
27
28
|
import * as grid from './grid';
|
28
29
|
import * as notificationCard from './notificationCard';
|
@@ -56,6 +57,7 @@ const components = {
|
|
56
57
|
uploadFile,
|
57
58
|
buttonSelectionGroupItem,
|
58
59
|
buttonSelectionGroup,
|
60
|
+
buttonMultiSelectionGroup,
|
59
61
|
modal,
|
60
62
|
grid,
|
61
63
|
notificationCard,
|
package/dist/umd/descope-button-selection-group-descope-button-selection-group-internal-index-js.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
"use strict";(self.webpackChunkDescopeUI=self.webpackChunkDescopeUI||[]).push([[1348],{3547:(e,t,s)=>{s.d(t,{B:()=>a,f:()=>n});var i=s(3878),l=s(4567),r=s(7878);const n=(0,l.iY)("button-selection-group-internal");class a extends((0,i.P)({componentName:n,baseSelector:"slot"})){constructor(){super(),this.innerHTML='\n <style>\n slot {\n box-sizing: border-box;\n width: 100%;\n display: flex;\n flex-wrap: wrap;\n }\n </style>\n <slot part="wrapper"></slot>\n\t\t'}#e=r.C.bind(this,"change");get items(){return this.querySelector("slot").assignedElements()}get isReadonly(){return"true"===this.getAttribute("readonly")}getSelectedNode(){return this.items.find((e=>e.hasAttribute("selected")))}get size(){return this.getAttribute("size")||"md"}get allowDeselect(){return"true"===this.getAttribute("allow-deselect")}removeSelected(){this.getSelectedNode()?.removeAttribute("selected")}onClick(e){e.target!==e.currentTarget&&(e.target===this.getSelectedNode()&&this.allowDeselect?this.removeSelected():this.setSelected(e.target),this.#e())}setSelected(e){e!==this.getSelectedNode()&&(this.removeSelected(),e?.setAttribute("selected","true"))}get value(){return this.getSelectedNode()?.value||""}set value(e){const t=this.items.find((t=>t.value===e));this.setSelected(t)}get defaultValue(){return this.getAttribute("default-value")}setDefaultValue(){setTimeout((()=>{this.defaultValue&&(this.value=this.defaultValue,this.setCustomValidity())}))}onSizeChange(){this.items.forEach((e=>{e.setAttribute("size",this.size)}))}onReadOnlyChange(){this.querySelector("slot").toggleAttribute("inert",this.isReadonly)}getValidity(){return this.isRequired&&!this.value?{valueMissing:!0}:{}}onObservedAttributeChange(e){e.forEach((e=>{switch(e){case"size":this.onSizeChange();break;case"readonly":this.onReadOnlyChange()}}))}init(){this.addEventListener("focus",(e=>{e.isTrusted&&this.items[0]?.focus()})),super.init?.(),this.setDefaultValue(),(0,l.FX)(this,this.onObservedAttributeChange.bind(this),{includeAttrs:["size","readonly"]}),this.querySelector("slot").addEventListener("click",this.onClick.bind(this))}}},8460:(e,t,s)=>{s.r(t),s.d(t,{ButtonSelectionGroupInternalClass:()=>i.B});var i=s(3547);customElements.define(i.f,i.B)}}]);
|
package/dist/umd/descope-button-selection-group-descope-button-selection-group-item-index-js.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
"use strict";(self.webpackChunkDescopeUI=self.webpackChunkDescopeUI||[]).push([[206],{7901:(t,e,o)=>{o.r(e),o.d(e,{ButtonSelectionGroupItemClass:()=>u});var s=o(1e3),n=o(2561),r=o(2061),i=o(4567),a=o(9690);const c=(0,i.iY)("button-selection-group-item");class l extends((0,n.s)({componentName:c,baseSelector:":host > descope-button"})){get size(){return this.getAttribute("size")||"md"}get variant(){return this.getAttribute("variant")||"contained"}get value(){return this.getAttribute("value")||""}set value(t){this.setAttribute("value",t)}constructor(){super(),this.attachShadow({mode:"open"}).innerHTML=`\n\t\t<style>\n descope-button {\n max-width: 100%;\n }\n\t\t\tdescope-button > slot {\n\t\t\t\twidth: 100%;\n\t\t\t\toverflow: hidden;\n text-overflow: ellipsis;\n display: inline-block;\n\t\t\t}\n\t\t\t:host {\n\t\t\t\tdisplay: inline-block;\n max-width: 100%\n\t\t\t}\n\t\t</style>\n <descope-button variant="${this.variant}" size="${this.size}" mode="primary">\n <slot></slot>\n </descope-button>\n\t`,(0,i.oP)(this,this.baseElement,{includeAttrs:["size","variant"]})}handleFocus(){this.shadowRoot.querySelector("descope-button")?.focus()}focus(){this.handleFocus()}init(){super.init(),this.addEventListener("focus",(t=>{t.isTrusted&&this.handleFocus()}))}}const u=(0,r.qC)((0,s.yk)({mappings:{hostDirection:{selector:()=>a.n.componentName,property:a.n.cssVarList.hostDirection},backgroundColor:{selector:()=>a.n.componentName,property:a.n.cssVarList.backgroundColor},labelTextColor:{selector:()=>a.n.componentName,property:a.n.cssVarList.labelTextColor},borderColor:{selector:()=>a.n.componentName,property:a.n.cssVarList.borderColor},borderStyle:{selector:()=>a.n.componentName,property:a.n.cssVarList.borderStyle},borderRadius:{selector:()=>a.n.componentName,property:a.n.cssVarList.borderRadius}}}),s.e4,s.Ae)(l);o(2018),customElements.define(c,u)}}]);
|
@@ -1 +0,0 @@
|
|
1
|
-
"use strict";(self.webpackChunkDescopeUI=self.webpackChunkDescopeUI||[]).push([[6699],{8086:(t,e,n)=>{n.r(e),n.d(e,{ButtonSelectionGroupClass:()=>m});var r=n(1e3),i=n(3547),a=n(2061),s=n(4567),o=n(4201);const d=(0,s.iY)("button-selection-group"),{host:l,label:p,requiredIndicator:c,internalWrapper:u,errorMessage:h}={host:{selector:()=>":host"},label:{selector:"::part(label)"},requiredIndicator:{selector:"[required]::part(required-indicator)::after"},internalWrapper:{selector:"descope-button-selection-group-internal slot"},errorMessage:{selector:"::part(error-message)"}},m=(0,a.qC)((0,r.yk)({mappings:{hostWidth:{...l,property:"width"},hostDirection:{...l,property:"direction"},fontFamily:l,labelTextColor:[{...p,property:"color"},{...c,property:"color"}],labelRequiredIndicator:{...c,property:"content"},errorMessageTextColor:{...h,property:"color"},itemsSpacing:{...u,property:"gap"}}}),r.e4,(0,r.dj)({proxyProps:["value","selectionStart"]}),r.Ae,(t=>class extends t{#t=({value:t,label:e})=>`<descope-button-selection-group-item value="${t}">${e}</descope-button-selection-group-item>`;#e;get renderItem(){return this.#t}set renderItem(t){this.#t=t,this.renderItems()}get size(){return this.inputElement?.size}get data(){if(this.#e)return this.#e;const t=this.getAttribute("data");if(t)try{const e=JSON.parse(t);if(this.isValidDataType(e))return e}catch(t){console.error('could not parse data string from attribute "data" - ',t.message)}return[]}set data(t){this.isValidDataType(t)&&(this.#e=t,this.renderItems())}isValidDataType(t){const e=Array.isArray(t);return e||console.error("data must be an array, received:",t),e}getItemsTemplate(){return this.data?.reduce?.(((t,e)=>t+(this.renderItem?.(e||{})||"")),"")}renderItems(){const t=this.getItemsTemplate();t&&(this.innerHTML=t)}init(){super.init?.();const t=document.createElement("template");t.innerHTML=`\n\t\t\t<${i.f}\n\t\t\t\tname="button-selection-group"\n\t\t\t\tslot="input"\n tabindex="-1"\n\t\t\t>\n <slot></slot>\n </${i.f}>\n\t\t\t`,this.baseElement.appendChild(t.content.cloneNode(!0)),this.inputElement=this.shadowRoot.querySelector(i.f),(0,s.oP)(this,this.inputElement,{includeAttrs:["size","default-value","allow-deselect"]}),this.renderItems(),(0,s.FX)(this,this.renderItems.bind(this),{includeAttrs:["data"]}),(0,s.P$)(this,(({addedNodes:t})=>{t.forEach((t=>{t.setAttribute("size",this.size)}))}))}}))((0,r.DM)({slots:[],wrappedEleName:"vaadin-text-field",style:()=>`\n\t\t\t:host {\n\t\t\t\tdisplay: inline-flex;\n\t\t\t\tmax-width: 100%;\n\t\t\t}\n\t\t\t${(0,o.DY)()}\n\t\t\t:host::after {\n\t\t\t\tbackground-color: transparent;\n\t\t\t}\n\t\t\t:host::part(input-field)::after {\n\t\t\t\tbackground-color: transparent;\n\t\t\t}\n\n\t\t\tdescope-button-selection-group-internal {\n\t\t\t\t-webkit-mask-image: none;\n\t\t\t\tpadding: 0;\n\t\t\t\twidth: 100%;\n\t\t\t\theight: 100%;\n display: inline-block;\n\t\t\t\tmin-height: initial;\n\t\t\t}\n\n\t\t\tvaadin-text-field::part(input-field) {\n\t\t\t\tbackground-color: transparent;\n\t\t\t\tpadding: 0;\n\t\t\t\toverflow: hidden;\n\t\t\t\t-webkit-mask-image: none;\n\t\t\t}\n\n\t\t\tvaadin-text-field {\n\t\t\t\tmargin: 0;\n\t\t\t\tpadding: 0;\n\t\t\t\twidth: 100%\n\t\t\t}\n\n\t\t\tvaadin-text-field::before {\n\t\t\t\theight: 0;\n\t\t\t}\n\n\t\t\tvaadin-text-field[readonly] > input:placeholder-shown {\n\t\t\t\topacity: 1;\n\t\t\t}\n\n\t\t\tvaadin-text-field[readonly]::part(input-field)::after {\n\t\t\t\tborder: 0 solid;\n\t\t\t}\n\n\t\t\tvaadin-text-field::part(input-field) {\n\t\t\t\tbox-shadow: none;\n\t\t\t}\n\n ${(0,o.Wf)("vaadin-text-field")}\n\t\t\t${(0,o.Pd)("vaadin-text-field")}\n `,excludeAttrsSync:["tabindex"],componentName:d}));n(8460),n(7901),customElements.define(d,m)}}]);
|
@@ -1,145 +0,0 @@
|
|
1
|
-
import { createBaseInputClass } from '../../../baseClasses/createBaseInputClass';
|
2
|
-
import { getComponentName, observeAttributes } from '../../../helpers/componentHelpers';
|
3
|
-
import { createDispatchEvent } from '../../../helpers/mixinsHelpers';
|
4
|
-
|
5
|
-
export const componentName = getComponentName('button-selection-group-internal');
|
6
|
-
|
7
|
-
export class ButtonSelectionGroupInternalClass extends createBaseInputClass({
|
8
|
-
componentName,
|
9
|
-
baseSelector: 'slot',
|
10
|
-
}) {
|
11
|
-
constructor() {
|
12
|
-
super();
|
13
|
-
|
14
|
-
this.innerHTML = `
|
15
|
-
<style>
|
16
|
-
slot {
|
17
|
-
box-sizing: border-box;
|
18
|
-
width: 100%;
|
19
|
-
display: flex;
|
20
|
-
flex-wrap: wrap;
|
21
|
-
}
|
22
|
-
</style>
|
23
|
-
<slot part="wrapper"></slot>
|
24
|
-
`;
|
25
|
-
}
|
26
|
-
|
27
|
-
#dispatchChange = createDispatchEvent.bind(this, 'change');
|
28
|
-
|
29
|
-
get items() {
|
30
|
-
return this.querySelector('slot').assignedElements();
|
31
|
-
}
|
32
|
-
|
33
|
-
get isReadonly() {
|
34
|
-
return this.getAttribute('readonly') === 'true';
|
35
|
-
}
|
36
|
-
|
37
|
-
getSelectedNode() {
|
38
|
-
return this.items.find((item) => item.hasAttribute('selected'));
|
39
|
-
}
|
40
|
-
|
41
|
-
get size() {
|
42
|
-
return this.getAttribute('size') || 'md';
|
43
|
-
}
|
44
|
-
|
45
|
-
get allowDeselect() {
|
46
|
-
return this.getAttribute('allow-deselect') === 'true';
|
47
|
-
}
|
48
|
-
|
49
|
-
removeSelected() {
|
50
|
-
this.getSelectedNode()?.removeAttribute('selected');
|
51
|
-
}
|
52
|
-
|
53
|
-
onClick(e) {
|
54
|
-
if (e.target !== e.currentTarget) {
|
55
|
-
if (e.target === this.getSelectedNode() && this.allowDeselect) {
|
56
|
-
this.removeSelected();
|
57
|
-
} else {
|
58
|
-
this.setSelected(e.target);
|
59
|
-
}
|
60
|
-
this.#dispatchChange();
|
61
|
-
}
|
62
|
-
}
|
63
|
-
|
64
|
-
setSelected(node) {
|
65
|
-
if (node !== this.getSelectedNode()) {
|
66
|
-
this.removeSelected();
|
67
|
-
node?.setAttribute('selected', 'true');
|
68
|
-
}
|
69
|
-
}
|
70
|
-
|
71
|
-
get value() {
|
72
|
-
return this.getSelectedNode()?.value || '';
|
73
|
-
}
|
74
|
-
|
75
|
-
set value(value) {
|
76
|
-
const node = this.items.find((child) => child.value === value);
|
77
|
-
this.setSelected(node);
|
78
|
-
}
|
79
|
-
|
80
|
-
get defaultValue() {
|
81
|
-
return this.getAttribute('default-value');
|
82
|
-
}
|
83
|
-
|
84
|
-
setDefaultValue() {
|
85
|
-
// we want to defer this action until all attributes are synched
|
86
|
-
setTimeout(() => {
|
87
|
-
if (this.defaultValue) {
|
88
|
-
this.value = this.defaultValue;
|
89
|
-
this.setCustomValidity();
|
90
|
-
}
|
91
|
-
});
|
92
|
-
}
|
93
|
-
|
94
|
-
onSizeChange() {
|
95
|
-
this.items.forEach((item) => {
|
96
|
-
item.setAttribute('size', this.size);
|
97
|
-
});
|
98
|
-
}
|
99
|
-
|
100
|
-
onReadOnlyChange() {
|
101
|
-
this.querySelector('slot').toggleAttribute('inert', this.isReadonly);
|
102
|
-
}
|
103
|
-
|
104
|
-
getValidity() {
|
105
|
-
if (this.isRequired && !this.value) {
|
106
|
-
return { valueMissing: true };
|
107
|
-
}
|
108
|
-
|
109
|
-
return {};
|
110
|
-
}
|
111
|
-
|
112
|
-
onObservedAttributeChange(attrs) {
|
113
|
-
attrs.forEach((attr) => {
|
114
|
-
switch (attr) {
|
115
|
-
case 'size':
|
116
|
-
this.onSizeChange();
|
117
|
-
break;
|
118
|
-
case 'readonly':
|
119
|
-
this.onReadOnlyChange();
|
120
|
-
break;
|
121
|
-
default:
|
122
|
-
break;
|
123
|
-
}
|
124
|
-
});
|
125
|
-
}
|
126
|
-
|
127
|
-
init() {
|
128
|
-
// we are adding listeners before calling to super because it's stopping the events
|
129
|
-
this.addEventListener('focus', (e) => {
|
130
|
-
// we want to ignore focus events we are dispatching
|
131
|
-
if (e.isTrusted) {
|
132
|
-
this.items[0]?.focus();
|
133
|
-
}
|
134
|
-
});
|
135
|
-
|
136
|
-
super.init?.();
|
137
|
-
this.setDefaultValue();
|
138
|
-
|
139
|
-
observeAttributes(this, this.onObservedAttributeChange.bind(this), {
|
140
|
-
includeAttrs: ['size', 'readonly'],
|
141
|
-
});
|
142
|
-
|
143
|
-
this.querySelector('slot').addEventListener('click', this.onClick.bind(this));
|
144
|
-
}
|
145
|
-
}
|
File without changes
|
File without changes
|