@descope/web-components-ui 1.0.364 → 1.0.366

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. package/dist/cjs/index.cjs.js +1896 -1301
  2. package/dist/cjs/index.cjs.js.map +1 -1
  3. package/dist/index.esm.js +1963 -1371
  4. package/dist/index.esm.js.map +1 -1
  5. package/dist/umd/4978.js +1 -1
  6. package/dist/umd/DescopeDev.js +1 -1
  7. package/dist/umd/button-selection-group-fields-descope-button-multi-selection-group-index-js.js +1 -1
  8. package/dist/umd/button-selection-group-fields-descope-button-selection-group-index-js.js +1 -1
  9. package/dist/umd/button-selection-group-fields-descope-button-selection-group-item-index-js.js +1 -1
  10. package/dist/umd/descope-apps-list-index-js.js +1 -0
  11. package/dist/umd/descope-avatar-index-js.js +1 -1
  12. package/dist/umd/descope-button-index-js.js +2 -2
  13. package/dist/umd/descope-icon-index-js.js +1 -1
  14. package/dist/umd/descope-list-index-js.js +1 -0
  15. package/dist/umd/descope-upload-file-index-js.js +1 -1
  16. package/dist/umd/descope-user-attribute-index-js.js +1 -1
  17. package/dist/umd/descope-user-auth-method-index-js.js +1 -1
  18. package/dist/umd/index.js +1 -1
  19. package/dist/umd/mapping-fields-descope-mappings-field-index-js.js +1 -1
  20. package/package.json +1 -1
  21. package/src/components/descope-apps-list/AppsListClass.js +98 -0
  22. package/src/components/descope-apps-list/index.js +8 -0
  23. package/src/components/descope-avatar/AvatarClass.js +5 -2
  24. package/src/components/descope-button/ButtonClass.js +7 -1
  25. package/src/components/descope-icon/IconClass.js +50 -20
  26. package/src/components/descope-icon/helpers.js +39 -0
  27. package/src/components/descope-list/ListClass.js +140 -0
  28. package/src/components/descope-list/ListItemClass.js +56 -0
  29. package/src/components/descope-list/index.js +7 -0
  30. package/src/index.cjs.js +3 -0
  31. package/src/mixins/activableMixin.js +14 -0
  32. package/src/mixins/createDynamicDataMixin.js +84 -0
  33. package/src/mixins/createProxy.js +1 -1
  34. package/src/theme/components/appsList.js +36 -0
  35. package/src/theme/components/button.js +3 -0
  36. package/src/theme/components/index.js +6 -0
  37. package/src/theme/components/list/list.js +56 -0
  38. package/src/theme/components/list/listItem.js +41 -0
@@ -0,0 +1,140 @@
1
+ import { createStyleMixin, draggableMixin, componentNameValidationMixin } from '../../mixins';
2
+ import { createBaseClass } from '../../baseClasses/createBaseClass';
3
+ import { compose } from '../../helpers';
4
+ import { getComponentName, observeChildren } from '../../helpers/componentHelpers';
5
+ import { ListItemClass } from './ListItemClass';
6
+
7
+ export const componentName = getComponentName('list');
8
+
9
+ class RawList extends createBaseClass({ componentName, baseSelector: '.wrapper' }) {
10
+ static get observedAttributes() {
11
+ return ['variant'];
12
+ }
13
+
14
+ constructor() {
15
+ super();
16
+
17
+ this.attachShadow({ mode: 'open' }).innerHTML = `
18
+ <style>
19
+ /*css*/
20
+ .wrapper {
21
+ overflow: auto;
22
+ display: grid;
23
+ max-height: 100%;
24
+ width: 100%;
25
+ }
26
+
27
+ :host {
28
+ display: inline-flex;
29
+ width: 100%;
30
+ }
31
+ slot[name="empty-state"] {
32
+ justify-content: center;
33
+ align-items: center;
34
+ display: flex;
35
+ flex-grow: 1;
36
+ }
37
+
38
+ :host slot[name="empty-state"] {
39
+ display: none;
40
+ }
41
+ :host([empty]) slot[name="empty-state"] {
42
+ display: flex;
43
+ }
44
+ ::slotted(:not([slot])) {
45
+ width: 100%;
46
+ }
47
+ /*!css*/
48
+ </style>
49
+
50
+ <div class="wrapper">
51
+ <slot></slot>
52
+ <slot name="empty-state">
53
+ No item...
54
+ </slot>
55
+ </div>
56
+ `;
57
+ }
58
+
59
+ get items() {
60
+ return this.shadowRoot.querySelector('slot').assignedElements();
61
+ }
62
+
63
+ #handleEmptyState() {
64
+ if (this.items.length === 0) {
65
+ this.setAttribute('empty', 'true');
66
+ } else {
67
+ this.removeAttribute('empty');
68
+ }
69
+ }
70
+
71
+ get variant() {
72
+ return this.getAttribute('variant') || 'list';
73
+ }
74
+
75
+ #handleItemsVariant() {
76
+ this.items.forEach((item) => {
77
+ let listItem = item;
78
+ if (listItem.localName !== ListItemClass.componentName) {
79
+ listItem = item.querySelector(ListItemClass.componentName);
80
+ }
81
+
82
+ const listItemVariant = this.variant === 'tiles' ? 'tile' : 'row';
83
+ listItem.setAttribute('variant', listItemVariant);
84
+ });
85
+ }
86
+
87
+ init() {
88
+ super.init?.();
89
+
90
+ // we want new items to get the size
91
+ observeChildren(this, () => {
92
+ this.#handleEmptyState();
93
+ this.#handleItemsVariant();
94
+ });
95
+ }
96
+
97
+ attributeChangedCallback(name, oldValue, newValue) {
98
+ super.attributeChangedCallback?.(name, oldValue, newValue);
99
+
100
+ if (newValue === oldValue) return;
101
+
102
+ if (name === 'variant') {
103
+ this.#handleItemsVariant();
104
+ }
105
+ }
106
+ }
107
+
108
+ export const ListClass = compose(
109
+ createStyleMixin({
110
+ mappings: {
111
+ hostWidth: { selector: () => ':host', property: 'width' },
112
+ maxHeight: { selector: () => ':host' },
113
+ minHeight: {},
114
+ verticalPadding: [{ property: 'padding-top' }, { property: 'padding-bottom' }],
115
+ horizontalPadding: [{ property: 'padding-left' }, { property: 'padding-right' }],
116
+ hostDirection: { selector: () => ':host', property: 'direction' },
117
+ fontFamily: {},
118
+ gap: {},
119
+
120
+ backgroundColor: {},
121
+ borderRadius: {},
122
+ borderColor: {},
123
+ borderStyle: {},
124
+ borderWidth: {},
125
+
126
+ boxShadow: {},
127
+ gridTemplateColumns: {},
128
+ maxItemsWidth: { selector: () => '::slotted(:not([slot]))', property: 'max-width' },
129
+ minItemsWidth: { selector: () => '::slotted(:not([slot]))', property: 'min-width' },
130
+ itemsHorizontalAlign: { selector: () => '::slotted(*)', property: 'justify-self' },
131
+ emptyStateTextColor: { selector: () => 'slot[name="empty-state"]', property: 'color' },
132
+ emptyStateTextFontFamily: {
133
+ selector: () => 'slot[name="empty-state"]',
134
+ property: 'font-family',
135
+ },
136
+ },
137
+ }),
138
+ draggableMixin,
139
+ componentNameValidationMixin
140
+ )(RawList);
@@ -0,0 +1,56 @@
1
+ import { createStyleMixin, draggableMixin, componentNameValidationMixin } from '../../mixins';
2
+ import { createBaseClass } from '../../baseClasses/createBaseClass';
3
+ import { compose } from '../../helpers';
4
+ import { getComponentName } from '../../helpers/componentHelpers';
5
+ import { activeableMixin } from '../../mixins/activableMixin';
6
+
7
+ export const componentName = getComponentName('list-item');
8
+
9
+ const customMixin = (superclass) =>
10
+ class ListItemMixinClass extends superclass {
11
+ constructor() {
12
+ super();
13
+
14
+ this.attachShadow({ mode: 'open' }).innerHTML = `
15
+ <style>
16
+ /*css*/
17
+ slot {
18
+ width: 100%;
19
+ display: flex;
20
+ overflow: hidden;
21
+ box-sizing: border-box;
22
+ }
23
+ :host {
24
+ display: block;
25
+ }
26
+
27
+ /*!css*/
28
+ </style>
29
+ <slot></slot>
30
+ `;
31
+ }
32
+ };
33
+
34
+ export const ListItemClass = compose(
35
+ createStyleMixin({
36
+ mappings: {
37
+ padding: {},
38
+ backgroundColor: {},
39
+ borderColor: {},
40
+ borderStyle: {},
41
+ borderWidth: {},
42
+ borderRadius: {},
43
+ outline: {},
44
+ cursor: {},
45
+ gap: {},
46
+ maxWidth: { selector: () => ':host' },
47
+ alignItems: {},
48
+ flexDirection: {},
49
+ transition: {},
50
+ },
51
+ }),
52
+ draggableMixin,
53
+ componentNameValidationMixin,
54
+ customMixin,
55
+ activeableMixin
56
+ )(createBaseClass({ componentName, baseSelector: 'slot' }));
@@ -0,0 +1,7 @@
1
+ import { componentName as listComponentName, ListClass } from './ListClass';
2
+ import { componentName as listItemComponentName, ListItemClass } from './ListItemClass';
3
+
4
+ customElements.define(listComponentName, ListClass);
5
+ customElements.define(listItemComponentName, ListItemClass);
6
+
7
+ export { ListClass };
package/src/index.cjs.js CHANGED
@@ -47,3 +47,6 @@ export { PolicyValidationClass } from './components/descope-policy-validation/Po
47
47
  export { CodeSnippetClass } from './components/descope-code-snippet/CodeSnippetClass';
48
48
  export { RadioGroupClass } from './components/descope-radio-group/RadioGroupClass';
49
49
  export { RadioButtonClass } from './components/descope-radio-group/RadioButtonClass';
50
+ export { ListClass } from './components/descope-list/ListClass';
51
+ export { ListItemClass } from './components/descope-list/ListItemClass';
52
+ export { AppsListClass } from './components/descope-apps-list/AppsListClass';
@@ -0,0 +1,14 @@
1
+ export const activeableMixin = (superclass) =>
2
+ class ActiveableMixinClass extends superclass {
3
+ init() {
4
+ super.init?.();
5
+
6
+ this.baseElement.addEventListener('mousedown', (e) => {
7
+ e.preventDefault();
8
+ this.setAttribute('active', 'true');
9
+ window.addEventListener('mouseup', () => this.removeAttribute('active'), {
10
+ once: true,
11
+ });
12
+ });
13
+ }
14
+ };
@@ -0,0 +1,84 @@
1
+ import { observeAttributes } from '../helpers/componentHelpers';
2
+
3
+ const defaultValidateSchema = () => true;
4
+ const defaultItemRenderer = (item) => `<pre>${JSON.stringify(item, null, 4)}</pre>`;
5
+
6
+ const createTemplate = (templateString) => {
7
+ const template = document.createElement('template');
8
+ template.innerHTML = templateString;
9
+
10
+ return template;
11
+ };
12
+
13
+ const getTemplateContent = (templateOrString) => {
14
+ if (typeof templateOrString === 'string') {
15
+ return createTemplate(templateOrString).content;
16
+ }
17
+
18
+ if (templateOrString instanceof HTMLTemplateElement) {
19
+ return templateOrString.content;
20
+ }
21
+
22
+ // eslint-disable-next-line no-console
23
+ console.error('Invalid template', templateOrString);
24
+ return null;
25
+ };
26
+
27
+ export const createDynamicDataMixin =
28
+ ({
29
+ itemRenderer = defaultItemRenderer,
30
+ validateSchema = defaultValidateSchema,
31
+ slotName,
32
+ rerenderAttrsList = [],
33
+ }) =>
34
+ (superclass) =>
35
+ class DynamicDataMixinClass extends superclass {
36
+ #data = [];
37
+
38
+ // eslint-disable-next-line class-methods-use-this
39
+ #validateSchema(data) {
40
+ if (!validateSchema) return true;
41
+
42
+ const validation = validateSchema(data);
43
+ if (validation === true) return true;
44
+
45
+ // eslint-disable-next-line no-console
46
+ console.error('Data schema validation failed', validation || '');
47
+
48
+ return false;
49
+ }
50
+
51
+ #removeOldItems() {
52
+ const selector = slotName ? `*[slot="${slotName}"]` : ':not([slot])';
53
+ this.baseElement.querySelectorAll(selector).forEach((item) => item.remove());
54
+ }
55
+
56
+ #renderItems() {
57
+ this.#removeOldItems();
58
+ this.data.forEach((item, index) => {
59
+ const content = getTemplateContent(itemRenderer(item, index, this));
60
+ this.baseElement.appendChild(content?.cloneNode(true));
61
+ });
62
+ }
63
+
64
+ set data(value) {
65
+ if (this.#validateSchema(value)) {
66
+ this.#data = value;
67
+ this.#renderItems();
68
+ }
69
+ }
70
+
71
+ get data() {
72
+ return this.#data;
73
+ }
74
+
75
+ init() {
76
+ super.init?.();
77
+
78
+ if (rerenderAttrsList.length) {
79
+ observeAttributes(this, () => this.#renderItems(), { includeAttrs: rerenderAttrsList });
80
+ } else {
81
+ this.#renderItems();
82
+ }
83
+ }
84
+ };
@@ -26,7 +26,7 @@ export const createProxy = ({
26
26
  .map(
27
27
  (
28
28
  slot // when slot is an empty string, we will create the default slot (without a name)
29
- ) => `<slot ${slot ? `name="${slot}" slot="${slot}"` : ''} ></slot>`
29
+ ) => `<slot ${slot ? `name="${slot}" slot="${slot}"` : ''}></slot>`
30
30
  )
31
31
  .join('')}
32
32
  </${wrappedEleName}>
@@ -0,0 +1,36 @@
1
+ import { AppsListClass } from '../../components/descope-apps-list/AppsListClass';
2
+ import { getThemeRefs } from '../../helpers/themeHelpers';
3
+ import globals from '../globals';
4
+
5
+ export const vars = AppsListClass.cssVarList;
6
+ const globalRefs = getThemeRefs(globals);
7
+
8
+ const defaultHeight = '400px';
9
+
10
+ const appsList = {
11
+ [vars.itemsFontWeight]: 'normal',
12
+ [vars.itemsTextAlign]: 'start',
13
+ [vars.hostDirection]: globalRefs.direction,
14
+ [vars.maxHeight]: defaultHeight,
15
+
16
+ _empty: {
17
+ [vars.minHeight]: defaultHeight,
18
+ },
19
+
20
+ size: {
21
+ xs: {
22
+ [vars.itemsFontSize]: '14px',
23
+ },
24
+ sm: {
25
+ [vars.itemsFontSize]: '14px',
26
+ },
27
+ md: {
28
+ [vars.itemsFontSize]: '16px',
29
+ },
30
+ lg: {
31
+ [vars.itemsFontSize]: '20px',
32
+ },
33
+ },
34
+ };
35
+
36
+ export default appsList;
@@ -47,6 +47,9 @@ const button = {
47
47
  [compVars.outlineStyle]: 'solid',
48
48
  [compVars.outlineColor]: 'transparent',
49
49
 
50
+ [compVars.iconSize]: '1.5em',
51
+ [compVars.iconColor]: 'currentColor',
52
+
50
53
  size: {
51
54
  xs: { [compVars.fontSize]: '12px' },
52
55
  sm: { [compVars.fontSize]: '14px' },
@@ -41,6 +41,9 @@ import * as icon from './icon';
41
41
  import * as codeSnippet from './codeSnippet';
42
42
  import * as radioGroup from './radioGroup/radioGroup';
43
43
  import * as radioButton from './radioGroup/radioButton';
44
+ import * as list from './list/list';
45
+ import * as listItem from './list/listItem';
46
+ import * as appsList from './appsList';
44
47
 
45
48
  const components = {
46
49
  button,
@@ -87,6 +90,9 @@ const components = {
87
90
  codeSnippet,
88
91
  radioGroup,
89
92
  radioButton,
93
+ list,
94
+ listItem,
95
+ appsList,
90
96
  };
91
97
 
92
98
  const theme = Object.keys(components).reduce(
@@ -0,0 +1,56 @@
1
+ import globals from '../../globals';
2
+ import { getThemeRefs, createHelperVars, useVar } from '../../../helpers/themeHelpers';
3
+ import { ListClass, componentName } from '../../../components/descope-list/ListClass';
4
+
5
+ const globalRefs = getThemeRefs(globals);
6
+
7
+ const compVars = ListClass.cssVarList;
8
+
9
+ const [helperTheme, helperRefs, helperVars] = createHelperVars(
10
+ { shadowColor: '#00000020' },
11
+ componentName
12
+ );
13
+
14
+ const { shadowColor } = helperRefs;
15
+
16
+ const list = {
17
+ ...helperTheme,
18
+
19
+ [compVars.hostWidth]: '100%',
20
+ [compVars.backgroundColor]: globalRefs.colors.surface.main,
21
+ [compVars.fontFamily]: globalRefs.fonts.font1.family,
22
+ [compVars.borderColor]: globalRefs.colors.surface.light,
23
+ [compVars.borderStyle]: 'solid',
24
+ [compVars.borderWidth]: globalRefs.border.xs,
25
+ [compVars.borderRadius]: globalRefs.radius.sm,
26
+ [compVars.gap]: globalRefs.spacing.md,
27
+ [compVars.verticalPadding]: globalRefs.spacing.lg,
28
+ [compVars.horizontalPadding]: globalRefs.spacing.lg,
29
+ [compVars.boxShadow]: `${globalRefs.shadow.wide.sm} ${shadowColor}, ${globalRefs.shadow.narrow.sm} ${shadowColor}`,
30
+ [compVars.maxHeight]: '100%',
31
+ [compVars.hostDirection]: globalRefs.direction,
32
+ [compVars.minItemsWidth]: '150px',
33
+
34
+ _empty: {
35
+ [compVars.minHeight]: '150px',
36
+ [compVars.emptyStateTextColor]: globalRefs.colors.surface.dark,
37
+ [compVars.emptyStateTextFontFamily]: globalRefs.fonts.font1.family,
38
+ },
39
+
40
+ variant: {
41
+ tiles: {
42
+ [compVars.gridTemplateColumns]: `repeat(auto-fit, minmax(min(${useVar(
43
+ compVars.minItemsWidth
44
+ )}, 100%), 1fr))`,
45
+ [compVars.maxItemsWidth]: '200px',
46
+ [compVars.itemsHorizontalAlign]: 'center',
47
+ },
48
+ },
49
+ };
50
+
51
+ export default list;
52
+
53
+ export const vars = {
54
+ ...compVars,
55
+ ...helperVars,
56
+ };
@@ -0,0 +1,41 @@
1
+ import globals from '../../globals';
2
+ import { getThemeRefs } from '../../../helpers/themeHelpers';
3
+ import { ListItemClass } from '../../../components/descope-list/ListItemClass';
4
+
5
+ const globalRefs = getThemeRefs(globals);
6
+
7
+ export const vars = ListItemClass.cssVarList;
8
+
9
+ const list = {
10
+ [vars.backgroundColor]: globalRefs.colors.surface.main,
11
+ [vars.padding]: globalRefs.spacing.lg,
12
+ [vars.gap]: globalRefs.spacing.md,
13
+ [vars.borderStyle]: 'solid',
14
+ [vars.borderWidth]: globalRefs.border.xs,
15
+ [vars.borderColor]: globalRefs.colors.surface.main,
16
+ [vars.borderRadius]: globalRefs.radius.sm,
17
+ [vars.cursor]: 'pointer',
18
+ [vars.alignItems]: 'center',
19
+ [vars.flexDirection]: 'row',
20
+ [vars.transition]: 'border-color 0.2s, background-color 0.2s',
21
+
22
+ variant: {
23
+ tile: {
24
+ [vars.alignItems]: 'flex-start',
25
+ [vars.flexDirection]: 'column',
26
+ [vars.borderColor]: globalRefs.colors.surface.light,
27
+ },
28
+ },
29
+
30
+ _hover: {
31
+ [vars.backgroundColor]: globalRefs.colors.surface.highlight,
32
+ },
33
+
34
+ _active: {
35
+ [vars.backgroundColor]: globalRefs.colors.surface.main,
36
+ [vars.borderColor]: globalRefs.colors.primary.light,
37
+ [vars.outline]: `1px solid ${globalRefs.colors.primary.light}`,
38
+ },
39
+ };
40
+
41
+ export default list;