@descope/web-components-ui 1.0.366 → 1.0.368

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/index.esm.js CHANGED
@@ -849,6 +849,7 @@ const inputValidationMixin = (superclass) =>
849
849
  badInput,
850
850
  customError,
851
851
  } = flags;
852
+
852
853
  switch (true) {
853
854
  case valueMissing:
854
855
  return (
@@ -861,7 +862,9 @@ const inputValidationMixin = (superclass) =>
861
862
  );
862
863
  case typeMismatch:
863
864
  return (
864
- this.getAttribute(errorAttributes.typeMismatch) || this.defaultErrorMsgTypeMismatch
865
+ this.getAttribute(errorAttributes.typeMismatch) ||
866
+ this.getAttribute(errorAttributes.patternMismatch) ||
867
+ this.defaultErrorMsgTypeMismatch
865
868
  );
866
869
  case tooShort:
867
870
  return this.getAttribute(errorAttributes.tooShort) || this.defaultErrorMsgTooShort;
@@ -11874,132 +11877,509 @@ const RadioGroupClass = compose(
11874
11877
  customElements.define(componentName$4, RadioGroupClass);
11875
11878
  customElements.define(componentName$5, RadioButtonClass);
11876
11879
 
11877
- const getVarName = (path) => getCssVarName(DESCOPE_PREFIX, ...path);
11880
+ const activeableMixin = (superclass) =>
11881
+ class ActiveableMixinClass extends superclass {
11882
+ init() {
11883
+ super.init?.();
11878
11884
 
11879
- // lodash.set alternative
11880
- const set = (obj, path, value) => {
11881
- const pathArray = Array.isArray(path) ? path : path.match(/([^[.\]])+/g);
11885
+ this.baseElement.addEventListener('mousedown', (e) => {
11886
+ e.preventDefault();
11887
+ this.setAttribute('active', 'true');
11888
+ window.addEventListener('mouseup', () => this.removeAttribute('active'), {
11889
+ once: true,
11890
+ });
11891
+ });
11892
+ }
11893
+ };
11882
11894
 
11883
- pathArray.reduce((acc, key, i) => {
11884
- if (acc[key] === undefined) acc[key] = {};
11885
- if (i === pathArray.length - 1) acc[key] = value;
11886
- return acc[key];
11887
- }, obj);
11895
+ const componentName$3 = getComponentName('list-item');
11888
11896
 
11889
- return obj;
11890
- };
11897
+ const customMixin$1 = (superclass) =>
11898
+ class ListItemMixinClass extends superclass {
11899
+ constructor() {
11900
+ super();
11891
11901
 
11892
- const transformTheme = (theme, path, getTransformation) => {
11893
- return Object.entries(theme).reduce((acc, [key, val]) => {
11894
- if (val?.constructor !== Object) {
11895
- return merge(acc, getTransformation(path.concat(key), val));
11902
+ this.attachShadow({ mode: 'open' }).innerHTML = `
11903
+ <style>
11904
+ /*css*/
11905
+ slot {
11906
+ width: 100%;
11907
+ display: flex;
11908
+ overflow: hidden;
11909
+ box-sizing: border-box;
11910
+ }
11911
+ :host {
11912
+ display: block;
11913
+ }
11914
+
11915
+ /*!css*/
11916
+ </style>
11917
+ <slot></slot>
11918
+ `;
11896
11919
  }
11897
- return merge(acc, transformTheme(val, [...path, key], getTransformation));
11898
- }, {});
11899
- };
11920
+ };
11900
11921
 
11901
- const stringifyArray = (strArr) =>
11902
- strArr.map((str) => (str.includes(' ') ? `"${str}"` : str)).join(', ');
11922
+ const ListItemClass = compose(
11923
+ createStyleMixin({
11924
+ mappings: {
11925
+ padding: {},
11926
+ backgroundColor: {},
11927
+ borderColor: {},
11928
+ borderStyle: {},
11929
+ borderWidth: {},
11930
+ borderRadius: {},
11931
+ outline: {},
11932
+ cursor: {},
11933
+ gap: {},
11934
+ maxWidth: { selector: () => ':host' },
11935
+ alignItems: {},
11936
+ flexDirection: {},
11937
+ transition: {},
11938
+ },
11939
+ }),
11940
+ draggableMixin,
11941
+ componentNameValidationMixin,
11942
+ customMixin$1,
11943
+ activeableMixin
11944
+ )(createBaseClass({ componentName: componentName$3, baseSelector: 'slot' }));
11903
11945
 
11904
- const getCssVarValue = (val) => {
11905
- switch (true) {
11906
- case Array.isArray(val):
11907
- return stringifyArray(val);
11908
- case isUrl(val):
11909
- return `url(${val})`;
11910
- default:
11911
- return val;
11912
- }
11913
- };
11946
+ const componentName$2 = getComponentName('list');
11914
11947
 
11915
- const themeToCSSVarsObj = (theme) =>
11916
- transformTheme(theme, [], (path, val) => ({
11917
- [getVarName(path)]: getCssVarValue(val),
11918
- }));
11948
+ class RawList extends createBaseClass({ componentName: componentName$2, baseSelector: '.wrapper' }) {
11949
+ static get observedAttributes() {
11950
+ return ['variant'];
11951
+ }
11919
11952
 
11920
- const getThemeRefs = (theme, prefix) =>
11921
- transformTheme(theme, [], (path) =>
11922
- set({}, path, `var(${getVarName(prefix ? [prefix, ...path] : path)})`)
11923
- );
11953
+ constructor() {
11954
+ super();
11924
11955
 
11925
- const getThemeVars = (theme, prefix) =>
11926
- transformTheme(theme, [], (path) => set({}, path, getVarName(prefix ? [prefix, ...path] : path)));
11956
+ this.attachShadow({ mode: 'open' }).innerHTML = `
11957
+ <style>
11958
+ /*css*/
11959
+ .wrapper {
11960
+ overflow: auto;
11961
+ display: grid;
11962
+ max-height: 100%;
11963
+ width: 100%;
11964
+ }
11927
11965
 
11928
- const globalsThemeToStyle = (theme, themeName = '') => {
11929
- const style = Object.entries(themeToCSSVarsObj(theme)).reduce(
11930
- (acc, entry) => `${acc}${entry.join(':')};\n`,
11931
- ''
11932
- );
11966
+ :host {
11967
+ display: inline-flex;
11968
+ width: 100%;
11969
+ }
11970
+ slot[name="empty-state"] {
11971
+ justify-content: center;
11972
+ align-items: center;
11973
+ display: flex;
11974
+ flex-grow: 1;
11975
+ }
11933
11976
 
11934
- if (!themeName) return style;
11977
+ :host slot[name="empty-state"] {
11978
+ display: none;
11979
+ }
11980
+ :host([empty]) slot[name="empty-state"] {
11981
+ display: flex;
11982
+ }
11983
+ ::slotted(:not([slot])) {
11984
+ width: 100%;
11985
+ }
11986
+ /*!css*/
11987
+ </style>
11935
11988
 
11936
- return `*[data-theme="${themeName}"] {${style}}`;
11937
- };
11989
+ <div class="wrapper">
11990
+ <slot></slot>
11991
+ <slot name="empty-state">
11992
+ No item...
11993
+ </slot>
11994
+ </div>
11995
+ `;
11996
+ }
11938
11997
 
11939
- const componentsThemeToStyleObj = (componentsTheme) =>
11940
- transformTheme(componentsTheme, [], (path, val) => {
11941
- const [component, ...restPath] = path;
11942
- const property = restPath.pop();
11943
- const componentName = getComponentName(component);
11998
+ get items() {
11999
+ return this.shadowRoot.querySelector('slot').assignedElements();
12000
+ }
11944
12001
 
11945
- if (property === 'undefined') {
11946
- // eslint-disable-next-line no-console
11947
- console.warn(componentName, `theme value: "${val}" is mapped to an invalid property`);
12002
+ #handleEmptyState() {
12003
+ if (this.items.length === 0) {
12004
+ this.setAttribute('empty', 'true');
12005
+ } else {
12006
+ this.removeAttribute('empty');
11948
12007
  }
12008
+ }
11949
12009
 
11950
- // we need a support for portal components theme (e.g. overlay)
11951
- // this allows us to generate those themes under different sections
11952
- // if the theme has root level attribute that starts with #
11953
- // we are generating a new theme
11954
- let themeName = BASE_THEME_SECTION;
12010
+ get variant() {
12011
+ return this.getAttribute('variant') || 'list';
12012
+ }
11955
12013
 
11956
- if (restPath[0] && restPath[0].startsWith(PORTAL_THEME_PREFIX)) {
11957
- themeName = restPath.shift();
11958
- }
12014
+ #handleItemsVariant() {
12015
+ this.items.forEach((item) => {
12016
+ let listItem = item;
12017
+ if (listItem.localName !== ListItemClass.componentName) {
12018
+ listItem = item.querySelector(ListItemClass.componentName);
12019
+ }
11959
12020
 
11960
- // do not start with underscore -> key:value, must have 2 no underscore attrs in a row
11961
- // starts with underscore -> attribute selector
11962
- const attrsSelector = restPath.reduce((acc, section, idx) => {
11963
- if (section.startsWith('_')) return `${acc}[${kebabCase(section.replace(/^_/, ''))}="true"]`;
12021
+ const listItemVariant = this.variant === 'tiles' ? 'tile' : 'row';
12022
+ listItem.setAttribute('variant', listItemVariant);
12023
+ });
12024
+ }
11964
12025
 
11965
- const nextSection = restPath[idx + 1];
12026
+ init() {
12027
+ super.init?.();
11966
12028
 
11967
- if (typeof nextSection !== 'string' || nextSection.startsWith('_')) {
11968
- // eslint-disable-next-line no-console
11969
- console.error(
11970
- 'theme generator',
11971
- `your theme structure is invalid, attribute "${section}" is followed by "${nextSection}" which is not allowed`
11972
- );
11973
- return acc;
11974
- }
12029
+ // we want new items to get the size
12030
+ observeChildren(this, () => {
12031
+ this.#handleEmptyState();
12032
+ this.#handleItemsVariant();
12033
+ });
12034
+ }
11975
12035
 
11976
- return `${acc}[${kebabCase(section)}="${restPath.splice(idx + 1, 1).join('')}"]`;
11977
- }, '');
12036
+ attributeChangedCallback(name, oldValue, newValue) {
12037
+ super.attributeChangedCallback?.(name, oldValue, newValue);
11978
12038
 
11979
- const selector = `:host${attrsSelector ? `(${attrsSelector})` : ''}`;
12039
+ if (newValue === oldValue) return;
11980
12040
 
11981
- return {
11982
- [componentName]: {
11983
- [themeName]: {
11984
- [selector]: {
11985
- [property]: getCssVarValue(val),
11986
- },
11987
- },
11988
- },
11989
- };
11990
- });
12041
+ if (name === 'variant') {
12042
+ this.#handleItemsVariant();
12043
+ }
12044
+ }
12045
+ }
11991
12046
 
11992
- const componentsThemeToStyle = (componentsTheme) =>
11993
- Object.entries(componentsTheme).reduce(
11994
- (acc, [selector, vars]) =>
11995
- `${acc}${selector} { \n${Object.entries(vars)
11996
- .map(([key, val]) => `${key}: ${val}`)
11997
- .join(';\n')} \n}\n\n`,
11998
- ''
11999
- );
12047
+ const ListClass = compose(
12048
+ createStyleMixin({
12049
+ mappings: {
12050
+ hostWidth: { selector: () => ':host', property: 'width' },
12051
+ maxHeight: { selector: () => ':host' },
12052
+ minHeight: {},
12053
+ verticalPadding: [{ property: 'padding-top' }, { property: 'padding-bottom' }],
12054
+ horizontalPadding: [{ property: 'padding-left' }, { property: 'padding-right' }],
12055
+ hostDirection: { selector: () => ':host', property: 'direction' },
12056
+ fontFamily: {},
12057
+ gap: {},
12000
12058
 
12001
- const createComponentsTheme = (componentsTheme) => {
12002
- const styleObj = componentsThemeToStyleObj(componentsTheme);
12059
+ backgroundColor: {},
12060
+ borderRadius: {},
12061
+ borderColor: {},
12062
+ borderStyle: {},
12063
+ borderWidth: {},
12064
+
12065
+ boxShadow: {},
12066
+ gridTemplateColumns: {},
12067
+ maxItemsWidth: { selector: () => '::slotted(:not([slot]))', property: 'max-width' },
12068
+ minItemsWidth: { selector: () => '::slotted(:not([slot]))', property: 'min-width' },
12069
+ itemsHorizontalAlign: { selector: () => '::slotted(*)', property: 'justify-self' },
12070
+ emptyStateTextColor: { selector: () => 'slot[name="empty-state"]', property: 'color' },
12071
+ emptyStateTextFontFamily: {
12072
+ selector: () => 'slot[name="empty-state"]',
12073
+ property: 'font-family',
12074
+ },
12075
+ },
12076
+ }),
12077
+ draggableMixin,
12078
+ componentNameValidationMixin
12079
+ )(RawList);
12080
+
12081
+ customElements.define(componentName$2, ListClass);
12082
+ customElements.define(componentName$3, ListItemClass);
12083
+
12084
+ const defaultValidateSchema = () => true;
12085
+ const defaultItemRenderer = (item) => `<pre>${JSON.stringify(item, null, 4)}</pre>`;
12086
+
12087
+ const createTemplate = (templateString) => {
12088
+ const template = document.createElement('template');
12089
+ template.innerHTML = templateString;
12090
+
12091
+ return template;
12092
+ };
12093
+
12094
+ const getTemplateContent = (templateOrString) => {
12095
+ if (typeof templateOrString === 'string') {
12096
+ return createTemplate(templateOrString).content;
12097
+ }
12098
+
12099
+ if (templateOrString instanceof HTMLTemplateElement) {
12100
+ return templateOrString.content;
12101
+ }
12102
+
12103
+ // eslint-disable-next-line no-console
12104
+ console.error('Invalid template', templateOrString);
12105
+ return null;
12106
+ };
12107
+
12108
+ const createDynamicDataMixin =
12109
+ ({
12110
+ itemRenderer = defaultItemRenderer,
12111
+ validateSchema = defaultValidateSchema,
12112
+ slotName,
12113
+ rerenderAttrsList = [],
12114
+ }) =>
12115
+ (superclass) =>
12116
+ class DynamicDataMixinClass extends superclass {
12117
+ #data = [];
12118
+
12119
+ // eslint-disable-next-line class-methods-use-this
12120
+ #validateSchema(data) {
12121
+ if (!validateSchema) return true;
12122
+
12123
+ const validation = validateSchema(data);
12124
+ if (validation === true) return true;
12125
+
12126
+ // eslint-disable-next-line no-console
12127
+ console.error('Data schema validation failed', validation || '');
12128
+
12129
+ return false;
12130
+ }
12131
+
12132
+ #removeOldItems() {
12133
+ const selector = slotName ? `*[slot="${slotName}"]` : ':not([slot])';
12134
+ this.baseElement.querySelectorAll(selector).forEach((item) => item.remove());
12135
+ }
12136
+
12137
+ #renderItems() {
12138
+ this.#removeOldItems();
12139
+ this.data.forEach((item, index) => {
12140
+ const content = getTemplateContent(itemRenderer(item, index, this));
12141
+ this.baseElement.appendChild(content?.cloneNode(true));
12142
+ });
12143
+ }
12144
+
12145
+ set data(value) {
12146
+ if (this.#validateSchema(value)) {
12147
+ this.#data = value;
12148
+ this.#renderItems();
12149
+ }
12150
+ }
12151
+
12152
+ get data() {
12153
+ return this.#data;
12154
+ }
12155
+
12156
+ init() {
12157
+ super.init?.();
12158
+
12159
+ if (rerenderAttrsList.length) {
12160
+ observeAttributes(this, () => this.#renderItems(), { includeAttrs: rerenderAttrsList });
12161
+ } else {
12162
+ this.#renderItems();
12163
+ }
12164
+ }
12165
+ };
12166
+
12167
+ const componentName$1 = getComponentName('apps-list');
12168
+
12169
+ const limitAbbreviation = (str, limit = 3) =>
12170
+ str
12171
+ .trim()
12172
+ .split(' ')
12173
+ .splice(0, limit)
12174
+ .map((s) => s[0]?.toUpperCase())
12175
+ .join('');
12176
+
12177
+ const itemRenderer = ({ name, icon, url }, _, ref) => `
12178
+ <a href="${url}" target="_blank" title="${url}">
12179
+ <descope-list-item>
12180
+ <descope-avatar
12181
+ img="${icon}"
12182
+ display-name="${name}"
12183
+ abbr=${limitAbbreviation(name)}
12184
+ size=${ref.size}
12185
+ ></descope-avatar>
12186
+ <descope-text
12187
+ variant="body1"
12188
+ mode="primary"
12189
+ >${name}</descope-text>
12190
+ </descope-list-item>
12191
+ </a>
12192
+ `;
12193
+
12194
+ const customMixin = (superclass) =>
12195
+ class AppsListMixinClass extends superclass {
12196
+ get size() {
12197
+ return this.getAttribute('size') || 'sm';
12198
+ }
12199
+ };
12200
+
12201
+ const AppsListClass = compose(
12202
+ createStyleMixin({
12203
+ mappings: {
12204
+ maxHeight: { selector: () => ':host' },
12205
+ minHeight: { selector: () => ':host' },
12206
+ hostDirection: { selector: () => ':host', property: 'direction' },
12207
+ itemsFontWeight: {
12208
+ selector: TextClass.componentName,
12209
+ property: TextClass.cssVarList.fontWeight,
12210
+ },
12211
+ itemsFontSize: {
12212
+ selector: TextClass.componentName,
12213
+ property: TextClass.cssVarList.fontSize,
12214
+ },
12215
+ itemsTextAlign: {
12216
+ selector: TextClass.componentName,
12217
+ property: TextClass.cssVarList.textAlign,
12218
+ },
12219
+ },
12220
+ }),
12221
+ createDynamicDataMixin({ itemRenderer, rerenderAttrsList: ['size'] }),
12222
+ draggableMixin,
12223
+ componentNameValidationMixin,
12224
+ customMixin
12225
+ )(
12226
+ createProxy({
12227
+ slots: ['empty-state'],
12228
+ wrappedEleName: 'descope-list',
12229
+ excludeAttrsSync: ['tabindex', 'class'],
12230
+ componentName: componentName$1,
12231
+ style: () => `
12232
+ :host {
12233
+ width: 100%;
12234
+ display: inline-flex;
12235
+ }
12236
+
12237
+ descope-text::part(text-wrapper) {
12238
+ display: -webkit-box;
12239
+ -webkit-line-clamp: 2;
12240
+ -webkit-box-orient: vertical;
12241
+ overflow: hidden;
12242
+ }
12243
+
12244
+ a {
12245
+ text-decoration: none;
12246
+ }
12247
+
12248
+ descope-text {
12249
+ ${TextClass.cssVarList.hostDirection}: var(${AppsListClass.cssVarList.hostDirection});
12250
+ }
12251
+ `,
12252
+ })
12253
+ );
12254
+
12255
+ customElements.define(componentName$1, AppsListClass);
12256
+
12257
+ const getVarName = (path) => getCssVarName(DESCOPE_PREFIX, ...path);
12258
+
12259
+ // lodash.set alternative
12260
+ const set = (obj, path, value) => {
12261
+ const pathArray = Array.isArray(path) ? path : path.match(/([^[.\]])+/g);
12262
+
12263
+ pathArray.reduce((acc, key, i) => {
12264
+ if (acc[key] === undefined) acc[key] = {};
12265
+ if (i === pathArray.length - 1) acc[key] = value;
12266
+ return acc[key];
12267
+ }, obj);
12268
+
12269
+ return obj;
12270
+ };
12271
+
12272
+ const transformTheme = (theme, path, getTransformation) => {
12273
+ return Object.entries(theme).reduce((acc, [key, val]) => {
12274
+ if (val?.constructor !== Object) {
12275
+ return merge(acc, getTransformation(path.concat(key), val));
12276
+ }
12277
+ return merge(acc, transformTheme(val, [...path, key], getTransformation));
12278
+ }, {});
12279
+ };
12280
+
12281
+ const stringifyArray = (strArr) =>
12282
+ strArr.map((str) => (str.includes(' ') ? `"${str}"` : str)).join(', ');
12283
+
12284
+ const getCssVarValue = (val) => {
12285
+ switch (true) {
12286
+ case Array.isArray(val):
12287
+ return stringifyArray(val);
12288
+ case isUrl(val):
12289
+ return `url(${val})`;
12290
+ default:
12291
+ return val;
12292
+ }
12293
+ };
12294
+
12295
+ const themeToCSSVarsObj = (theme) =>
12296
+ transformTheme(theme, [], (path, val) => ({
12297
+ [getVarName(path)]: getCssVarValue(val),
12298
+ }));
12299
+
12300
+ const getThemeRefs = (theme, prefix) =>
12301
+ transformTheme(theme, [], (path) =>
12302
+ set({}, path, `var(${getVarName(prefix ? [prefix, ...path] : path)})`)
12303
+ );
12304
+
12305
+ const getThemeVars = (theme, prefix) =>
12306
+ transformTheme(theme, [], (path) => set({}, path, getVarName(prefix ? [prefix, ...path] : path)));
12307
+
12308
+ const globalsThemeToStyle = (theme, themeName = '') => {
12309
+ const style = Object.entries(themeToCSSVarsObj(theme)).reduce(
12310
+ (acc, entry) => `${acc}${entry.join(':')};\n`,
12311
+ ''
12312
+ );
12313
+
12314
+ if (!themeName) return style;
12315
+
12316
+ return `*[data-theme="${themeName}"] {${style}}`;
12317
+ };
12318
+
12319
+ const componentsThemeToStyleObj = (componentsTheme) =>
12320
+ transformTheme(componentsTheme, [], (path, val) => {
12321
+ const [component, ...restPath] = path;
12322
+ const property = restPath.pop();
12323
+ const componentName = getComponentName(component);
12324
+
12325
+ if (property === 'undefined') {
12326
+ // eslint-disable-next-line no-console
12327
+ console.warn(componentName, `theme value: "${val}" is mapped to an invalid property`);
12328
+ }
12329
+
12330
+ // we need a support for portal components theme (e.g. overlay)
12331
+ // this allows us to generate those themes under different sections
12332
+ // if the theme has root level attribute that starts with #
12333
+ // we are generating a new theme
12334
+ let themeName = BASE_THEME_SECTION;
12335
+
12336
+ if (restPath[0] && restPath[0].startsWith(PORTAL_THEME_PREFIX)) {
12337
+ themeName = restPath.shift();
12338
+ }
12339
+
12340
+ // do not start with underscore -> key:value, must have 2 no underscore attrs in a row
12341
+ // starts with underscore -> attribute selector
12342
+ const attrsSelector = restPath.reduce((acc, section, idx) => {
12343
+ if (section.startsWith('_')) return `${acc}[${kebabCase(section.replace(/^_/, ''))}="true"]`;
12344
+
12345
+ const nextSection = restPath[idx + 1];
12346
+
12347
+ if (typeof nextSection !== 'string' || nextSection.startsWith('_')) {
12348
+ // eslint-disable-next-line no-console
12349
+ console.error(
12350
+ 'theme generator',
12351
+ `your theme structure is invalid, attribute "${section}" is followed by "${nextSection}" which is not allowed`
12352
+ );
12353
+ return acc;
12354
+ }
12355
+
12356
+ return `${acc}[${kebabCase(section)}="${restPath.splice(idx + 1, 1).join('')}"]`;
12357
+ }, '');
12358
+
12359
+ const selector = `:host${attrsSelector ? `(${attrsSelector})` : ''}`;
12360
+
12361
+ return {
12362
+ [componentName]: {
12363
+ [themeName]: {
12364
+ [selector]: {
12365
+ [property]: getCssVarValue(val),
12366
+ },
12367
+ },
12368
+ },
12369
+ };
12370
+ });
12371
+
12372
+ const componentsThemeToStyle = (componentsTheme) =>
12373
+ Object.entries(componentsTheme).reduce(
12374
+ (acc, [selector, vars]) =>
12375
+ `${acc}${selector} { \n${Object.entries(vars)
12376
+ .map(([key, val]) => `${key}: ${val}`)
12377
+ .join(';\n')} \n}\n\n`,
12378
+ ''
12379
+ );
12380
+
12381
+ const createComponentsTheme = (componentsTheme) => {
12382
+ const styleObj = componentsThemeToStyleObj(componentsTheme);
12003
12383
 
12004
12384
  return Object.keys(styleObj).reduce((acc, componentName) => {
12005
12385
  const componentThemes = styleObj[componentName];
@@ -12441,7 +12821,7 @@ var button$1 = /*#__PURE__*/Object.freeze({
12441
12821
  vars: vars$L
12442
12822
  });
12443
12823
 
12444
- const componentName$3 = getComponentName('input-wrapper');
12824
+ const componentName = getComponentName('input-wrapper');
12445
12825
  const globalRefs$u = getThemeRefs(globals);
12446
12826
 
12447
12827
  const [theme$1, refs, vars$K] = createHelperVars(
@@ -12550,7 +12930,7 @@ const [theme$1, refs, vars$K] = createHelperVars(
12550
12930
  backgroundColor: globalRefs$u.colors.surface.main,
12551
12931
  },
12552
12932
  },
12553
- componentName$3
12933
+ componentName
12554
12934
  );
12555
12935
 
12556
12936
  var inputWrapper = /*#__PURE__*/Object.freeze({
@@ -14355,262 +14735,61 @@ const radioGroup = {
14355
14735
  [vars$5.buttonsSpacing]: 'space-between',
14356
14736
  },
14357
14737
 
14358
- _disabled: {
14359
- [vars$5.itemsLabelColor]: globalRefs$4.colors.surface.light,
14360
- },
14361
- };
14362
-
14363
- var radioGroup$1 = /*#__PURE__*/Object.freeze({
14364
- __proto__: null,
14365
- default: radioGroup,
14366
- radioGroup: radioGroup,
14367
- vars: vars$5
14368
- });
14369
-
14370
- const vars$4 = RadioButtonClass.cssVarList;
14371
- const globalRefs$3 = getThemeRefs(globals);
14372
-
14373
- const radioButton = {
14374
- [vars$4.fontFamily]: refs.fontFamily,
14375
- [vars$4.radioSize]: 'calc(1em + 6px)',
14376
- [vars$4.radioMargin]: 'auto 4px',
14377
- [vars$4.radioCheckedSize]: `calc(var(${vars$4.radioSize})/5)`,
14378
- [vars$4.radioCheckedColor]: globalRefs$3.colors.surface.light,
14379
- [vars$4.radioBackgroundColor]: globalRefs$3.colors.surface.light,
14380
- [vars$4.radioBorderColor]: 'none',
14381
- [vars$4.radioBorderWidth]: 0,
14382
-
14383
- _checked: {
14384
- [vars$4.radioBackgroundColor]: globalRefs$3.colors.surface.contrast,
14385
- },
14386
-
14387
- _hover: {
14388
- cursor: 'pointer',
14389
- },
14390
-
14391
- size: {
14392
- xs: {
14393
- [vars$4.fontSize]: '12px',
14394
- },
14395
- sm: {
14396
- [vars$4.fontSize]: '14px',
14397
- },
14398
- md: {
14399
- [vars$4.fontSize]: '16px',
14400
- },
14401
- lg: {
14402
- [vars$4.fontSize]: '18px',
14403
- },
14404
- },
14405
- };
14406
-
14407
- var radioButton$1 = /*#__PURE__*/Object.freeze({
14408
- __proto__: null,
14409
- default: radioButton,
14410
- radioButton: radioButton,
14411
- vars: vars$4
14412
- });
14413
-
14414
- const activeableMixin = (superclass) =>
14415
- class ActiveableMixinClass extends superclass {
14416
- init() {
14417
- super.init?.();
14418
-
14419
- this.baseElement.addEventListener('mousedown', (e) => {
14420
- e.preventDefault();
14421
- this.setAttribute('active', 'true');
14422
- window.addEventListener('mouseup', () => this.removeAttribute('active'), {
14423
- once: true,
14424
- });
14425
- });
14426
- }
14427
- };
14428
-
14429
- const componentName$2 = getComponentName('list-item');
14430
-
14431
- const customMixin$1 = (superclass) =>
14432
- class ListItemMixinClass extends superclass {
14433
- constructor() {
14434
- super();
14435
-
14436
- this.attachShadow({ mode: 'open' }).innerHTML = `
14437
- <style>
14438
- /*css*/
14439
- slot {
14440
- width: 100%;
14441
- display: flex;
14442
- overflow: hidden;
14443
- box-sizing: border-box;
14444
- }
14445
- :host {
14446
- display: block;
14447
- }
14448
-
14449
- /*!css*/
14450
- </style>
14451
- <slot></slot>
14452
- `;
14453
- }
14454
- };
14455
-
14456
- const ListItemClass = compose(
14457
- createStyleMixin({
14458
- mappings: {
14459
- padding: {},
14460
- backgroundColor: {},
14461
- borderColor: {},
14462
- borderStyle: {},
14463
- borderWidth: {},
14464
- borderRadius: {},
14465
- outline: {},
14466
- cursor: {},
14467
- gap: {},
14468
- maxWidth: { selector: () => ':host' },
14469
- alignItems: {},
14470
- flexDirection: {},
14471
- transition: {},
14472
- },
14473
- }),
14474
- draggableMixin,
14475
- componentNameValidationMixin,
14476
- customMixin$1,
14477
- activeableMixin
14478
- )(createBaseClass({ componentName: componentName$2, baseSelector: 'slot' }));
14479
-
14480
- const componentName$1 = getComponentName('list');
14481
-
14482
- class RawList extends createBaseClass({ componentName: componentName$1, baseSelector: '.wrapper' }) {
14483
- static get observedAttributes() {
14484
- return ['variant'];
14485
- }
14486
-
14487
- constructor() {
14488
- super();
14489
-
14490
- this.attachShadow({ mode: 'open' }).innerHTML = `
14491
- <style>
14492
- /*css*/
14493
- .wrapper {
14494
- overflow: auto;
14495
- display: grid;
14496
- max-height: 100%;
14497
- width: 100%;
14498
- }
14499
-
14500
- :host {
14501
- display: inline-flex;
14502
- width: 100%;
14503
- }
14504
- slot[name="empty-state"] {
14505
- justify-content: center;
14506
- align-items: center;
14507
- display: flex;
14508
- flex-grow: 1;
14509
- }
14510
-
14511
- :host slot[name="empty-state"] {
14512
- display: none;
14513
- }
14514
- :host([empty]) slot[name="empty-state"] {
14515
- display: flex;
14516
- }
14517
- ::slotted(:not([slot])) {
14518
- width: 100%;
14519
- }
14520
- /*!css*/
14521
- </style>
14522
-
14523
- <div class="wrapper">
14524
- <slot></slot>
14525
- <slot name="empty-state">
14526
- No item...
14527
- </slot>
14528
- </div>
14529
- `;
14530
- }
14531
-
14532
- get items() {
14533
- return this.shadowRoot.querySelector('slot').assignedElements();
14534
- }
14535
-
14536
- #handleEmptyState() {
14537
- if (this.items.length === 0) {
14538
- this.setAttribute('empty', 'true');
14539
- } else {
14540
- this.removeAttribute('empty');
14541
- }
14542
- }
14543
-
14544
- get variant() {
14545
- return this.getAttribute('variant') || 'list';
14546
- }
14547
-
14548
- #handleItemsVariant() {
14549
- this.items.forEach((item) => {
14550
- let listItem = item;
14551
- if (listItem.localName !== ListItemClass.componentName) {
14552
- listItem = item.querySelector(ListItemClass.componentName);
14553
- }
14554
-
14555
- const listItemVariant = this.variant === 'tiles' ? 'tile' : 'row';
14556
- listItem.setAttribute('variant', listItemVariant);
14557
- });
14558
- }
14559
-
14560
- init() {
14561
- super.init?.();
14562
-
14563
- // we want new items to get the size
14564
- observeChildren(this, () => {
14565
- this.#handleEmptyState();
14566
- this.#handleItemsVariant();
14567
- });
14568
- }
14738
+ _disabled: {
14739
+ [vars$5.itemsLabelColor]: globalRefs$4.colors.surface.light,
14740
+ },
14741
+ };
14569
14742
 
14570
- attributeChangedCallback(name, oldValue, newValue) {
14571
- super.attributeChangedCallback?.(name, oldValue, newValue);
14743
+ var radioGroup$1 = /*#__PURE__*/Object.freeze({
14744
+ __proto__: null,
14745
+ default: radioGroup,
14746
+ radioGroup: radioGroup,
14747
+ vars: vars$5
14748
+ });
14572
14749
 
14573
- if (newValue === oldValue) return;
14750
+ const vars$4 = RadioButtonClass.cssVarList;
14751
+ const globalRefs$3 = getThemeRefs(globals);
14574
14752
 
14575
- if (name === 'variant') {
14576
- this.#handleItemsVariant();
14577
- }
14578
- }
14579
- }
14753
+ const radioButton = {
14754
+ [vars$4.fontFamily]: refs.fontFamily,
14755
+ [vars$4.radioSize]: 'calc(1em + 6px)',
14756
+ [vars$4.radioMargin]: 'auto 4px',
14757
+ [vars$4.radioCheckedSize]: `calc(var(${vars$4.radioSize})/5)`,
14758
+ [vars$4.radioCheckedColor]: globalRefs$3.colors.surface.light,
14759
+ [vars$4.radioBackgroundColor]: globalRefs$3.colors.surface.light,
14760
+ [vars$4.radioBorderColor]: 'none',
14761
+ [vars$4.radioBorderWidth]: 0,
14580
14762
 
14581
- const ListClass = compose(
14582
- createStyleMixin({
14583
- mappings: {
14584
- hostWidth: { selector: () => ':host', property: 'width' },
14585
- maxHeight: { selector: () => ':host' },
14586
- minHeight: {},
14587
- verticalPadding: [{ property: 'padding-top' }, { property: 'padding-bottom' }],
14588
- horizontalPadding: [{ property: 'padding-left' }, { property: 'padding-right' }],
14589
- hostDirection: { selector: () => ':host', property: 'direction' },
14590
- fontFamily: {},
14591
- gap: {},
14763
+ _checked: {
14764
+ [vars$4.radioBackgroundColor]: globalRefs$3.colors.surface.contrast,
14765
+ },
14592
14766
 
14593
- backgroundColor: {},
14594
- borderRadius: {},
14595
- borderColor: {},
14596
- borderStyle: {},
14597
- borderWidth: {},
14767
+ _hover: {
14768
+ cursor: 'pointer',
14769
+ },
14598
14770
 
14599
- boxShadow: {},
14600
- gridTemplateColumns: {},
14601
- maxItemsWidth: { selector: () => '::slotted(:not([slot]))', property: 'max-width' },
14602
- minItemsWidth: { selector: () => '::slotted(:not([slot]))', property: 'min-width' },
14603
- itemsHorizontalAlign: { selector: () => '::slotted(*)', property: 'justify-self' },
14604
- emptyStateTextColor: { selector: () => 'slot[name="empty-state"]', property: 'color' },
14605
- emptyStateTextFontFamily: {
14606
- selector: () => 'slot[name="empty-state"]',
14607
- property: 'font-family',
14608
- },
14771
+ size: {
14772
+ xs: {
14773
+ [vars$4.fontSize]: '12px',
14609
14774
  },
14610
- }),
14611
- draggableMixin,
14612
- componentNameValidationMixin
14613
- )(RawList);
14775
+ sm: {
14776
+ [vars$4.fontSize]: '14px',
14777
+ },
14778
+ md: {
14779
+ [vars$4.fontSize]: '16px',
14780
+ },
14781
+ lg: {
14782
+ [vars$4.fontSize]: '18px',
14783
+ },
14784
+ },
14785
+ };
14786
+
14787
+ var radioButton$1 = /*#__PURE__*/Object.freeze({
14788
+ __proto__: null,
14789
+ default: radioButton,
14790
+ radioButton: radioButton,
14791
+ vars: vars$4
14792
+ });
14614
14793
 
14615
14794
  const globalRefs$2 = getThemeRefs(globals);
14616
14795
 
@@ -14618,7 +14797,7 @@ const compVars = ListClass.cssVarList;
14618
14797
 
14619
14798
  const [helperTheme, helperRefs, helperVars] = createHelperVars(
14620
14799
  { shadowColor: '#00000020' },
14621
- componentName$1
14800
+ componentName$2
14622
14801
  );
14623
14802
 
14624
14803
  const { shadowColor } = helperRefs;
@@ -14711,177 +14890,6 @@ var listItem = /*#__PURE__*/Object.freeze({
14711
14890
  vars: vars$2
14712
14891
  });
14713
14892
 
14714
- const defaultValidateSchema = () => true;
14715
- const defaultItemRenderer = (item) => `<pre>${JSON.stringify(item, null, 4)}</pre>`;
14716
-
14717
- const createTemplate = (templateString) => {
14718
- const template = document.createElement('template');
14719
- template.innerHTML = templateString;
14720
-
14721
- return template;
14722
- };
14723
-
14724
- const getTemplateContent = (templateOrString) => {
14725
- if (typeof templateOrString === 'string') {
14726
- return createTemplate(templateOrString).content;
14727
- }
14728
-
14729
- if (templateOrString instanceof HTMLTemplateElement) {
14730
- return templateOrString.content;
14731
- }
14732
-
14733
- // eslint-disable-next-line no-console
14734
- console.error('Invalid template', templateOrString);
14735
- return null;
14736
- };
14737
-
14738
- const createDynamicDataMixin =
14739
- ({
14740
- itemRenderer = defaultItemRenderer,
14741
- validateSchema = defaultValidateSchema,
14742
- slotName,
14743
- rerenderAttrsList = [],
14744
- }) =>
14745
- (superclass) =>
14746
- class DynamicDataMixinClass extends superclass {
14747
- #data = [];
14748
-
14749
- // eslint-disable-next-line class-methods-use-this
14750
- #validateSchema(data) {
14751
- if (!validateSchema) return true;
14752
-
14753
- const validation = validateSchema(data);
14754
- if (validation === true) return true;
14755
-
14756
- // eslint-disable-next-line no-console
14757
- console.error('Data schema validation failed', validation || '');
14758
-
14759
- return false;
14760
- }
14761
-
14762
- #removeOldItems() {
14763
- const selector = slotName ? `*[slot="${slotName}"]` : ':not([slot])';
14764
- this.baseElement.querySelectorAll(selector).forEach((item) => item.remove());
14765
- }
14766
-
14767
- #renderItems() {
14768
- this.#removeOldItems();
14769
- this.data.forEach((item, index) => {
14770
- const content = getTemplateContent(itemRenderer(item, index, this));
14771
- this.baseElement.appendChild(content?.cloneNode(true));
14772
- });
14773
- }
14774
-
14775
- set data(value) {
14776
- if (this.#validateSchema(value)) {
14777
- this.#data = value;
14778
- this.#renderItems();
14779
- }
14780
- }
14781
-
14782
- get data() {
14783
- return this.#data;
14784
- }
14785
-
14786
- init() {
14787
- super.init?.();
14788
-
14789
- if (rerenderAttrsList.length) {
14790
- observeAttributes(this, () => this.#renderItems(), { includeAttrs: rerenderAttrsList });
14791
- } else {
14792
- this.#renderItems();
14793
- }
14794
- }
14795
- };
14796
-
14797
- const componentName = getComponentName('apps-list');
14798
-
14799
- const limitAbbreviation = (str, limit = 3) =>
14800
- str
14801
- .trim()
14802
- .split(' ')
14803
- .splice(0, limit)
14804
- .map((s) => s[0]?.toUpperCase())
14805
- .join('');
14806
-
14807
- const itemRenderer = ({ name, icon, url }, _, ref) => `
14808
- <a href="${url}" target="_blank" title="${url}">
14809
- <descope-list-item>
14810
- <descope-avatar
14811
- img="${icon}"
14812
- display-name="${name}"
14813
- abbr=${limitAbbreviation(name)}
14814
- size=${ref.size}
14815
- ></descope-avatar>
14816
- <descope-text
14817
- variant="body1"
14818
- mode="primary"
14819
- >${name}</descope-text>
14820
- </descope-list-item>
14821
- </a>
14822
- `;
14823
-
14824
- const customMixin = (superclass) =>
14825
- class AppsListMixinClass extends superclass {
14826
- get size() {
14827
- return this.getAttribute('size') || 'sm';
14828
- }
14829
- };
14830
-
14831
- const AppsListClass = compose(
14832
- createStyleMixin({
14833
- mappings: {
14834
- maxHeight: { selector: () => ':host' },
14835
- minHeight: { selector: () => ':host' },
14836
- hostDirection: { selector: () => ':host', property: 'direction' },
14837
- itemsFontWeight: {
14838
- selector: TextClass.componentName,
14839
- property: TextClass.cssVarList.fontWeight,
14840
- },
14841
- itemsFontSize: {
14842
- selector: TextClass.componentName,
14843
- property: TextClass.cssVarList.fontSize,
14844
- },
14845
- itemsTextAlign: {
14846
- selector: TextClass.componentName,
14847
- property: TextClass.cssVarList.textAlign,
14848
- },
14849
- },
14850
- }),
14851
- createDynamicDataMixin({ itemRenderer, rerenderAttrsList: ['size'] }),
14852
- draggableMixin,
14853
- componentNameValidationMixin,
14854
- customMixin
14855
- )(
14856
- createProxy({
14857
- slots: ['empty-state'],
14858
- wrappedEleName: 'descope-list',
14859
- excludeAttrsSync: ['tabindex', 'class'],
14860
- componentName,
14861
- style: () => `
14862
- :host {
14863
- width: 100%;
14864
- display: inline-flex;
14865
- }
14866
-
14867
- descope-text::part(text-wrapper) {
14868
- display: -webkit-box;
14869
- -webkit-line-clamp: 2;
14870
- -webkit-box-orient: vertical;
14871
- overflow: hidden;
14872
- }
14873
-
14874
- a {
14875
- text-decoration: none;
14876
- }
14877
-
14878
- descope-text {
14879
- ${TextClass.cssVarList.hostDirection}: var(${AppsListClass.cssVarList.hostDirection});
14880
- }
14881
- `,
14882
- })
14883
- );
14884
-
14885
14893
  const vars$1 = AppsListClass.cssVarList;
14886
14894
  const globalRefs = getThemeRefs(globals);
14887
14895
 
@@ -15028,5 +15036,5 @@ const darkTheme = merge({}, defaultTheme, {
15028
15036
  },
15029
15037
  });
15030
15038
 
15031
- export { AvatarClass, BadgeClass, ButtonClass, ButtonMultiSelectionGroupClass, ButtonSelectionGroupClass, CheckboxClass, CodeSnippetClass, ComboBoxClass, ContainerClass, DividerClass, EmailFieldClass, EnrichedTextClass, GridClass, IconClass, ImageClass, LinkClass, LoaderLinearClass, LoaderRadialClass, LogoClass, MappingsFieldClass, ModalClass, MultiSelectComboBoxClass, NewPasswordClass, NotificationClass, NotpImageClass, NumberFieldClass, PasscodeClass, PasswordClass, PhoneFieldClass, PhoneFieldInputBoxClass, PolicyValidationClass, RadioGroupClass, RecaptchaClass, SamlGroupMappingsClass, SwitchToggleClass, TextAreaClass, TextClass, TextFieldClass, TotpImageClass, UploadFileClass, UserAttributeClass, UserAuthMethodClass, componentsThemeManager, createComponentsTheme, darkTheme, defaultTheme, genColor, globalsThemeToStyle, themeToStyle, themeVars };
15039
+ export { AppsListClass, AvatarClass, BadgeClass, ButtonClass, ButtonMultiSelectionGroupClass, ButtonSelectionGroupClass, CheckboxClass, CodeSnippetClass, ComboBoxClass, ContainerClass, DividerClass, EmailFieldClass, EnrichedTextClass, GridClass, IconClass, ImageClass, LinkClass, ListClass, LoaderLinearClass, LoaderRadialClass, LogoClass, MappingsFieldClass, ModalClass, MultiSelectComboBoxClass, NewPasswordClass, NotificationClass, NotpImageClass, NumberFieldClass, PasscodeClass, PasswordClass, PhoneFieldClass, PhoneFieldInputBoxClass, PolicyValidationClass, RadioGroupClass, RecaptchaClass, SamlGroupMappingsClass, SwitchToggleClass, TextAreaClass, TextClass, TextFieldClass, TotpImageClass, UploadFileClass, UserAttributeClass, UserAuthMethodClass, componentsThemeManager, createComponentsTheme, darkTheme, defaultTheme, genColor, globalsThemeToStyle, themeToStyle, themeVars };
15032
15040
  //# sourceMappingURL=index.esm.js.map