@nectary/components 2.8.3 → 2.8.5

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/dialog/index.js CHANGED
@@ -3,7 +3,7 @@ import '../icon';
3
3
  import '../stop-events';
4
4
  import '../title';
5
5
  import { defineCustomElement, getAttribute, getBooleanAttribute, getRect, isAttrTrue, updateAttribute, getReactEventHandler, NectaryElement, updateBooleanAttribute, setClass, isTargetEqual, isAttrEqual } from '../utils';
6
- const templateHTML = '<style>:host{display:contents;--sinch-comp-dialog-max-width:512px;--sinch-comp-dialog-max-height:50vh}#dialog{position:fixed;left:0;right:0;margin:auto;display:flex;flex-direction:column;padding:24px 0;max-width:var(--sinch-comp-dialog-max-width);max-height:unset;border-radius:var(--sinch-comp-dialog-shape-radius);box-sizing:border-box;contain:content;background-color:var(--sinch-comp-dialog-color-default-background-initial);border:none;box-shadow:var(--sinch-comp-dialog-shadow);outline:0}#dialog:not([open]){display:none}dialog::backdrop{background-color:#000;opacity:.55}#header{display:flex;flex-direction:row;align-items:flex-start;margin-bottom:12px;padding:0 24px;gap:8px;--sinch-global-size-icon:24px;--sinch-global-color-icon:var(--sinch-comp-dialog-color-default-icon-initial)}#caption{--sinch-global-color-text:var(--sinch-comp-dialog-color-default-title-initial);--sinch-comp-title-font:var(--sinch-comp-dialog-font-title)}#content{min-height:0;overflow:auto;max-height:var(--sinch-comp-dialog-max-height);padding:4px 24px}#action{display:flex;flex-direction:row;justify-content:flex-end;gap:16px;margin-top:20px;padding:0 24px}#action.empty{display:none}#close{position:relative;left:4px;top:-4px;margin-left:auto}</style><dialog id="dialog"><div id="header"><slot id="icon" name="icon"></slot><sinch-title id="caption" type="m" level="3"></sinch-title><sinch-icon-button id="close" size="s"><sinch-icon id="icon-close" slot="icon" name="close"></sinch-icon></sinch-icon-button></div><div id="content"><sinch-stop-events events="close"><slot name="content"></slot></sinch-stop-events></div><div id="action"><sinch-stop-events events="close"><slot name="buttons"></slot></sinch-stop-events></div></dialog>';
6
+ const templateHTML = '<style>:host{display:contents;--sinch-comp-dialog-max-width:512px;--sinch-comp-dialog-max-height:90vh;--sinch-comp-dialog-width:fit-content}#dialog{position:fixed;left:0;right:0;margin:auto;display:flex;flex-direction:column;padding:24px 0;width:var(--sinch-comp-dialog-width);max-width:var(--sinch-comp-dialog-max-width);max-height:var(--sinch-comp-dialog-max-height);border-radius:var(--sinch-comp-dialog-shape-radius);box-sizing:border-box;contain:content;background-color:var(--sinch-comp-dialog-color-default-background-initial);border:none;box-shadow:var(--sinch-comp-dialog-shadow);outline:0}#dialog:not([open]){display:none}dialog::backdrop{background-color:#000;opacity:.55}#header{display:flex;flex-direction:row;align-items:flex-start;margin-bottom:12px;padding:0 24px;gap:8px;--sinch-global-size-icon:24px;--sinch-global-color-icon:var(--sinch-comp-dialog-color-default-icon-initial)}#caption{--sinch-global-color-text:var(--sinch-comp-dialog-color-default-title-initial);--sinch-comp-title-font:var(--sinch-comp-dialog-font-title)}#content{min-height:0;overflow:auto;padding:4px 24px}#action{display:flex;flex-direction:row;justify-content:flex-end;gap:16px;margin-top:20px;padding:0 24px}#action.empty{display:none}#close{position:relative;left:4px;top:-4px;margin-left:auto}</style><dialog id="dialog"><div id="header"><slot id="icon" name="icon"></slot><sinch-title id="caption" type="m" level="3"></sinch-title><sinch-icon-button id="close" size="s"><sinch-icon id="icon-close" slot="icon" name="close"></sinch-icon></sinch-icon-button></div><div id="content"><sinch-stop-events events="close"><slot name="content"></slot></sinch-stop-events></div><div id="action"><sinch-stop-events events="close"><slot name="buttons"></slot></sinch-stop-events></div></dialog>';
7
7
  import { disableScroll, enableScroll } from './utils';
8
8
  const template = document.createElement('template');
9
9
  template.innerHTML = templateHTML;
package/input/index.js CHANGED
@@ -79,7 +79,7 @@ defineCustomElement('sinch-input', class extends NectaryElement {
79
79
  this.#controller = null;
80
80
  }
81
81
  static get observedAttributes() {
82
- return ['type', 'value', 'placeholder', 'mask', 'invalid', 'disabled', 'size', 'autocomplete', 'data-size', 'aria-label'];
82
+ return ['type', 'value', 'placeholder', 'mask', 'invalid', 'disabled', 'size', 'autocomplete', 'autofocus', 'data-size', 'aria-label'];
83
83
  }
84
84
  attributeChangedCallback(name, oldVal, newVal) {
85
85
  switch (name) {
@@ -150,6 +150,16 @@ defineCustomElement('sinch-input', class extends NectaryElement {
150
150
  updateBooleanAttribute(this, name, isDisabled);
151
151
  break;
152
152
  }
153
+ case 'autofocus':
154
+ {
155
+ if (isAttrEqual(oldVal, newVal)) {
156
+ return;
157
+ }
158
+ const isAutofocus = isAttrTrue(newVal);
159
+ this.#$input.autofocus = isAutofocus;
160
+ updateBooleanAttribute(this, name, isAutofocus);
161
+ break;
162
+ }
153
163
  case 'size':
154
164
  {
155
165
  updateAttribute(this, 'data-size', newVal);
@@ -208,6 +218,12 @@ defineCustomElement('sinch-input', class extends NectaryElement {
208
218
  get disabled() {
209
219
  return getBooleanAttribute(this, 'disabled');
210
220
  }
221
+ set autofocus(isAutofocus) {
222
+ updateBooleanAttribute(this, 'autofocus', isAutofocus);
223
+ }
224
+ get autofocus() {
225
+ return getBooleanAttribute(this, 'autofocus');
226
+ }
211
227
  set size(size) {
212
228
  updateLiteralAttribute(this, sizeValues, 'size', size);
213
229
  }
package/input/types.d.ts CHANGED
@@ -20,6 +20,8 @@ export type TSinchInputElement = HTMLElement & {
20
20
  invalid: boolean;
21
21
  /** Disabled */
22
22
  disabled: boolean;
23
+ /** Whether the input should be autocofused */
24
+ autofocus: boolean;
23
25
  /** Size, `m` by default */
24
26
  size: TSinchSize;
25
27
  selectionStart: number | null;
@@ -46,6 +48,8 @@ export type TSinchInputElement = HTMLElement & {
46
48
  setAttribute(name: 'invalid', value: ''): void;
47
49
  /** Disabled */
48
50
  setAttribute(name: 'disabled', value: ''): void;
51
+ /** Autofocus */
52
+ setAttribute(name: 'autofocus', value: ''): void;
49
53
  /** Size, `m` by default */
50
54
  setAttribute(name: 'size', value: TSinchSize): void;
51
55
  };
@@ -66,6 +70,8 @@ export type TSinchInputReact = TSinchElementReact<TSinchInputElement> & {
66
70
  invalid?: boolean;
67
71
  /** Disabled */
68
72
  disabled?: boolean;
73
+ /** Autofocus */
74
+ autofocus?: boolean;
69
75
  /** Size, `m` by default */
70
76
  size?: TSinchSize;
71
77
  /** Change value handler */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nectary/components",
3
- "version": "2.8.3",
3
+ "version": "2.8.5",
4
4
  "files": [
5
5
  "**/*/*.css",
6
6
  "**/*/*.json",
package/utils/debounce.js CHANGED
@@ -18,5 +18,5 @@ const createDebounce = (delayFn, cancelFn) => cb => {
18
18
  }
19
19
  };
20
20
  };
21
- export const debounceTimeout = ms => createDebounce(cb => global.setTimeout(cb, ms), global.clearTimeout);
22
- export const debounceAnimationFrame = createDebounce(global.requestAnimationFrame, global.cancelAnimationFrame);
21
+ export const debounceTimeout = ms => createDebounce(cb => globalThis.setTimeout(cb, ms), globalThis.clearTimeout);
22
+ export const debounceAnimationFrame = createDebounce(globalThis.requestAnimationFrame, globalThis.cancelAnimationFrame);
package/utils/throttle.js CHANGED
@@ -17,4 +17,4 @@ const createThrottle = (delayFn, cancelFn) => cb => {
17
17
  }
18
18
  };
19
19
  };
20
- export const throttleAnimationFrame = createThrottle(global.requestAnimationFrame, global.cancelAnimationFrame);
20
+ export const throttleAnimationFrame = createThrottle(globalThis.requestAnimationFrame, globalThis.cancelAnimationFrame);