@nectary/components 2.8.7 → 2.8.8

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.
@@ -1,4 +1,4 @@
1
- import { defineCustomElement, getAttribute, getBooleanAttribute, unpackCsv, getFirstCsvValue, getReactEventHandler, NectaryElement, updateAttribute, updateBooleanAttribute, updateCsv, getTargetByAttribute } from '../utils';
1
+ import { NectaryElement, defineCustomElement, getAttribute, getBooleanAttribute, getFirstCsvValue, getReactEventHandler, getTargetByAttribute, unpackCsv, updateAttribute, updateBooleanAttribute, updateCsv } from '../utils';
2
2
  const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-direction:column;box-sizing:border-box;width:100%;height:100%}::slotted(sinch-accordion-item){flex-shrink:1}</style><div id="wrapper"><slot></slot></div>';
3
3
  const template = document.createElement('template');
4
4
  template.innerHTML = templateHTML;
@@ -1,6 +1,6 @@
1
1
  import '../icon';
2
- import '../title';
3
2
  import '../text';
3
+ import '../title';
4
4
  import type { TSinchAccordionItemElement, TSinchAccordionItemReact } from './types';
5
5
  declare global {
6
6
  namespace JSX {
@@ -1,6 +1,6 @@
1
1
  import '../icon';
2
- import '../title';
3
2
  import '../text';
3
+ import '../title';
4
4
  import { defineCustomElement, getAttribute, getBooleanAttribute, getLiteralAttribute, isAttrEqual, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute, updateLiteralAttribute } from '../utils';
5
5
  const templateHTML = '<style>:host{display:block;outline:0;min-height:48px}#wrapper{display:flex;flex-direction:column;position:relative;width:100%;height:100%;box-sizing:border-box;overflow:hidden;border-bottom:1px solid var(--sinch-comp-accordion-color-default-border-initial)}:host(:last-child)>#wrapper{border-bottom:none}#button{all:initial;display:flex;position:relative;align-items:center;gap:8px;box-sizing:border-box;width:100%;height:48px;padding:0 4px 0 8px;cursor:pointer;--sinch-global-color-icon:var(--sinch-comp-accordion-color-default-icon-initial);--sinch-global-size-icon:var(--sinch-comp-accordion-size-icon)}#button>*{pointer-events:none}#button:disabled{cursor:initial;--sinch-global-color-icon:var(--sinch-comp-accordion-color-disabled-icon-initial)}#button:focus-visible::after{content:"";position:absolute;inset:0;border:2px solid var(--sinch-comp-accordion-color-default-outline-focus);pointer-events:none}#status-wrapper{display:none;width:18px;height:24px;padding:8px 8px 8px 2px;box-sizing:border-box}#status{width:8px;height:8px;border-radius:50%}:host([status]:not([status=""])) #status-wrapper{display:block}:host([status=success]) #status{background-color:var(--sinch-comp-accordion-color-default-status-success)}:host([status=warn]) #status{background-color:var(--sinch-comp-accordion-color-default-status-warning)}:host([status=error]) #status{background-color:var(--sinch-comp-accordion-color-default-status-error)}:host([status=info]) #status{background-color:var(--sinch-comp-accordion-color-default-status-info)}#title{flex:1;min-width:0;--sinch-comp-title-font:var(--sinch-comp-accordion-font-title);--sinch-global-color-text:var(--sinch-comp-accordion-color-default-title-initial)}#button:disabled>#title{--sinch-global-color-text:var(--sinch-comp-accordion-color-disabled-title-initial)}#content{display:none;overflow-y:auto;flex-shrink:1;min-height:0;padding:0 8px 12px}#dropdown-icon{transform:rotate(0);will-change:transform;transition:transform .25s ease-in-out}#button[aria-expanded=true]>#dropdown-icon{transform:rotate(180deg)}#button[aria-expanded=true]+#content{display:block}#optional{--sinch-comp-text-font:var(--sinch-comp-accordion-font-optional-text);--sinch-global-color-text:var(--sinch-comp-accordion-color-default-optional-text-initial)}#button:disabled>#optional{--sinch-global-color-text:var(--sinch-comp-accordion-color-disabled-optional-text-initial)}</style><div id="wrapper"><button id="button" aria-controls="content" aria-expanded="false"><div id="status-wrapper"><div id="status"></div></div><slot name="icon"></slot><sinch-title id="title" level="3" type="m" ellipsis></sinch-title><sinch-text id="optional" type="m"></sinch-text><sinch-icon id="dropdown-icon" name="keyboard_arrow_down"></sinch-icon></button><div id="content" role="region" aria-labelledby="button"><slot name="content"></slot></div></div>';
6
6
  import { statusValues } from './utils';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nectary/components",
3
- "version": "2.8.7",
3
+ "version": "2.8.8",
4
4
  "files": [
5
5
  "**/*/*.css",
6
6
  "**/*/*.json",
@@ -101,6 +101,13 @@ defineCustomElement('sinch-select-menu', class extends NectaryElement {
101
101
  get multiple() {
102
102
  return getBooleanAttribute(this, 'multiple');
103
103
  }
104
+ set searchable(isSearchable) {
105
+ updateBooleanAttribute(this, 'searchable', isSearchable);
106
+ }
107
+ get searchable() {
108
+ const searchableAttribute = this.getAttribute('searchable');
109
+ return searchableAttribute === null ? searchableAttribute : isAttrTrue(searchableAttribute);
110
+ }
104
111
  set 'search-placeholder'(placeholder) {
105
112
  updateAttribute(this.#$search, 'placeholder', placeholder);
106
113
  }
@@ -198,10 +205,10 @@ defineCustomElement('sinch-select-menu', class extends NectaryElement {
198
205
  }
199
206
  }
200
207
  #onOptionSlotChange = () => {
201
- const hasSearchableAttribute = this.hasAttribute('searchable');
208
+ const searchable = this.searchable;
202
209
  const options = this.#$optionSlot.assignedElements();
203
210
  const isEnoughOptions = options.length >= NUM_ITEMS_SEARCH;
204
- const isSearchActive = isEnoughOptions || hasSearchableAttribute;
211
+ const isSearchActive = isEnoughOptions && searchable !== false || Boolean(searchable);
205
212
  if (!isSearchActive) {
206
213
  updateAttribute(this.#$search, 'value', null);
207
214
  }
@@ -7,7 +7,7 @@ export type TSinchSelectMenuElement = HTMLElement & {
7
7
  /** Allows multiple selection */
8
8
  multiple: boolean;
9
9
  /** Enforce the search bar appearing, by default it appears above a certain number of options */
10
- searchable: boolean;
10
+ searchable: boolean | null;
11
11
  /** Text for search bar's placeholder */
12
12
  'search-placeholder': string;
13
13
  /** Change value event */
@@ -29,7 +29,7 @@ export type TSinchSelectMenuReact = TSinchElementReact<TSinchSelectMenuElement>
29
29
  /** Allows multiple selection */
30
30
  multiple?: boolean;
31
31
  /** Enforce the search bar appearing, by default it appears above a certain number of options */
32
- searchable?: boolean;
32
+ searchable?: boolean | null;
33
33
  /** Text for search bar's placeholder */
34
34
  'search-placeholder'?: string;
35
35
  /** Label that is used for a11y */
package/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { ClassAttributes, DOMAttributes, HTMLAttributes } from 'react'
1
+ import type { ClassAttributes, DOMAttributes, HTMLAttributes } from 'react';
2
2
 
3
3
  export type TSinchElementReact<TElement> =
4
4
  Pick<HTMLAttributes<HTMLElement>, 'id' | 'className' | 'style' | 'slot' | 'children'> &