@nectary/components 2.2.1 → 2.2.3
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/accordion/index.js +21 -16
- package/accordion-item/index.js +9 -17
- package/action-menu/index.js +6 -9
- package/action-menu-option/index.js +3 -7
- package/alert/index.js +12 -12
- package/avatar/index.js +26 -23
- package/badge/index.js +2 -2
- package/button/index.js +6 -4
- package/card/index.js +6 -6
- package/checkbox/index.js +3 -3
- package/chip/index.js +2 -2
- package/code-tag/index.js +6 -9
- package/color-menu/index.js +10 -17
- package/color-menu-option/index.d.ts +0 -1
- package/color-menu-option/index.js +2 -6
- package/color-swatch/index.js +9 -9
- package/date-picker/index.js +0 -3
- package/dialog/index.js +16 -10
- package/dialog/types.d.ts +2 -0
- package/emoji/index.js +3 -0
- package/field/index.js +4 -4
- package/file-drop/index.js +21 -19
- package/file-picker/index.js +18 -18
- package/file-status/index.js +8 -5
- package/flag/index.js +3 -0
- package/help-tooltip/index.d.ts +1 -0
- package/help-tooltip/index.js +2 -1
- package/horizontal-stepper/index.js +1 -4
- package/horizontal-stepper-item/index.js +0 -3
- package/icon-button/index.js +5 -6
- package/input/index.js +8 -5
- package/link/index.js +2 -2
- package/package.json +1 -1
- package/pagination/index.js +2 -6
- package/pop/index.js +5 -4
- package/popover/index.js +2 -2
- package/progress/index.js +4 -4
- package/progress-stepper/index.js +1 -4
- package/progress-stepper-item/index.js +5 -5
- package/radio/index.js +28 -24
- package/radio-option/index.js +12 -34
- package/rich-text/index.js +12 -12
- package/segment/index.js +5 -2
- package/segmented-control/index.js +42 -21
- package/segmented-control-option/index.js +23 -30
- package/segmented-icon-control/index.js +46 -26
- package/segmented-icon-control-option/index.js +25 -32
- package/select-button/index.js +3 -4
- package/select-menu/index.js +0 -3
- package/select-menu-option/index.js +2 -2
- package/skeleton/index.js +0 -3
- package/spinner/index.js +0 -3
- package/table-head-cell/index.js +2 -2
- package/table-row/index.js +2 -2
- package/tabs/index.js +7 -7
- package/tabs-icon-option/index.js +2 -2
- package/tabs-option/index.js +2 -2
- package/tag/index.js +5 -2
- package/text/index.js +5 -2
- package/textarea/index.js +12 -6
- package/tile-control/index.js +2 -2
- package/tile-control-option/index.js +0 -3
- package/time-picker/index.js +3 -4
- package/title/index.js +4 -4
- package/toast/index.js +0 -3
- package/toggle/index.js +2 -2
- package/tooltip/index.js +1 -1
- package/utils/dom.d.ts +1 -0
- package/utils/dom.js +5 -2
- package/vertical-stepper/index.js +1 -4
- package/vertical-stepper-item/index.js +0 -3
package/toggle/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineCustomElement, getAttribute, getBooleanAttribute, getReactEventHandler, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
|
|
1
|
+
import { defineCustomElement, getAttribute, getBooleanAttribute, getReactEventHandler, isAttrEqual, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
|
|
2
2
|
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#wrapper{position:relative;display:flex;flex-direction:row;align-items:center;box-sizing:border-box;width:100%;height:var(--sinch-local-size);--sinch-local-size:24px}:host([small]) #wrapper{--sinch-local-size:22px}#input{all:initial;display:block;position:absolute;left:0;top:2px;width:40px;height:20px;cursor:pointer;pointer-events:initial}:host([disabled]) #input{cursor:initial}:host(:focus-visible) #input::after{position:absolute;content:"";left:-4px;top:-4px;right:-4px;bottom:-4px;border:2px solid var(--sinch-comp-toggle-color-default-outline-focus);border-radius:18px;pointer-events:none}:host([small]) #input{width:32px;height:16px;top:3px}#knob-container{position:relative;box-sizing:border-box;width:40px;height:20px;border-radius:10px;pointer-events:none;padding:2px;background-color:var(--sinch-comp-toggle-color-default-background-initial);overflow:hidden}:host([small]) #knob-container{width:32px;height:16px;border-radius:8px}:host([checked]) #knob-container{background-color:var(--sinch-comp-toggle-color-checked-background-initial)}:host([disabled]) #knob-container{background-color:var(--sinch-comp-toggle-color-disabled-background-initial)}:host([checked][disabled]) #knob-container{background-color:var(--sinch-comp-toggle-color-checked-disabled-background-initial)}#knob{position:relative;box-sizing:border-box;width:16px;height:16px;border-radius:50%;background-color:var(--sinch-comp-toggle-color-default-knob-background-initial);box-shadow:var(--sinch-comp-toggle-shadow-knob-default);transform:translateX(0);transition:transform .1s ease-in-out;will-change:transform}:host([small]) #knob{width:12px;height:12px}:host([disabled]) #knob-container>#knob{box-shadow:var(--sinch-comp-toggle-shadow-knob-disabled)}:host([checked]) #knob-container>#knob{transform:translateX(20px)}:host([small][checked]) #knob-container>#knob{transform:translateX(16px)}#knob::after,#knob::before{font:var(--sinch-comp-toggle-font-size-m-inside-text);color:var(--sinch-comp-toggle-color-default-text-inside-initial);text-transform:uppercase;font-size:8px;line-height:16px;display:none;position:absolute;top:0;padding:0 3px}#knob::before{content:"on";right:100%}#knob::after{content:"off";left:100%}:host([labeled]:not([small])) #knob::after,:host([labeled]:not([small])) #knob::before{display:block}@media (prefers-reduced-motion){#knob{transition:none}}#label{flex:1;align-self:center;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;padding-left:8px;font:var(--sinch-comp-toggle-font-size-m-label);color:var(--sinch-comp-toggle-color-default-label-initial);cursor:pointer}#label:empty{display:none}:host([small]) #label{font:var(--sinch-comp-toggle-font-size-s-label)}:host([disabled]) #label{color:var(--sinch-comp-toggle-color-disabled-label-initial);cursor:initial}</style><div id="wrapper"><div id="input"></div><div id="knob-container"><div id="knob"></div></div><span id="label"></span></div>';
|
|
3
3
|
const template = document.createElement('template');
|
|
4
4
|
template.innerHTML = templateHTML;
|
|
@@ -36,7 +36,7 @@ defineCustomElement('sinch-toggle', class extends NectaryElement {
|
|
|
36
36
|
return ['checked', 'disabled', 'text', 'labeled', 'small'];
|
|
37
37
|
}
|
|
38
38
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
39
|
-
if (oldVal
|
|
39
|
+
if (isAttrEqual(oldVal, newVal)) {
|
|
40
40
|
return;
|
|
41
41
|
}
|
|
42
42
|
switch (name) {
|
package/tooltip/index.js
CHANGED
|
@@ -57,8 +57,8 @@ defineCustomElement('sinch-tooltip', class extends NectaryElement {
|
|
|
57
57
|
this.#updateText();
|
|
58
58
|
}
|
|
59
59
|
disconnectedCallback() {
|
|
60
|
-
this.#tooltipState.destroy();
|
|
61
60
|
super.disconnectedCallback();
|
|
61
|
+
this.#tooltipState.destroy();
|
|
62
62
|
this.#controller.abort();
|
|
63
63
|
this.#controller = null;
|
|
64
64
|
}
|
package/utils/dom.d.ts
CHANGED
|
@@ -30,4 +30,5 @@ export declare const getCssVar: (element: Element, variableName: string) => stri
|
|
|
30
30
|
export declare const getCssVars: (element: Element, variableNames: string[]) => (string | null)[];
|
|
31
31
|
export declare const cloneNode: (el: Element, deep: boolean) => Element;
|
|
32
32
|
export declare const shouldReduceMotion: () => boolean;
|
|
33
|
+
export declare const isAttrEqual: (oldVal: string | null, newVal: string | null) => boolean;
|
|
33
34
|
export {};
|
package/utils/dom.js
CHANGED
|
@@ -2,7 +2,7 @@ export const updateExplicitBooleanAttribute = ($element, attrName, attrValue) =>
|
|
|
2
2
|
$element.setAttribute(attrName, attrValue === true ? 'true' : 'false');
|
|
3
3
|
};
|
|
4
4
|
export const isAttrTrue = attrValue => {
|
|
5
|
-
return attrValue
|
|
5
|
+
return attrValue !== null && attrValue !== 'false';
|
|
6
6
|
};
|
|
7
7
|
export const getBooleanAttribute = ($element, attrName) => {
|
|
8
8
|
return isAttrTrue($element.getAttribute(attrName));
|
|
@@ -148,4 +148,7 @@ export const cloneNode = (el, deep) => {
|
|
|
148
148
|
}
|
|
149
149
|
return el.cloneNode(deep);
|
|
150
150
|
};
|
|
151
|
-
export const shouldReduceMotion = () => window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
151
|
+
export const shouldReduceMotion = () => window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
152
|
+
export const isAttrEqual = (oldVal, newVal) => {
|
|
153
|
+
return oldVal === newVal || newVal === null && oldVal === 'false' || newVal === '' && oldVal === 'true';
|
|
154
|
+
};
|
|
@@ -21,10 +21,7 @@ defineCustomElement('sinch-vertical-stepper', class extends NectaryElement {
|
|
|
21
21
|
static get observedAttributes() {
|
|
22
22
|
return ['index'];
|
|
23
23
|
}
|
|
24
|
-
attributeChangedCallback(name
|
|
25
|
-
if (oldVal === newVal) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
24
|
+
attributeChangedCallback(name) {
|
|
28
25
|
switch (name) {
|
|
29
26
|
case 'index':
|
|
30
27
|
{
|
|
@@ -22,9 +22,6 @@ defineCustomElement('sinch-vertical-stepper-item', class extends NectaryElement
|
|
|
22
22
|
return ['label', 'description', 'data-index'];
|
|
23
23
|
}
|
|
24
24
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
25
|
-
if (oldVal === newVal) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
25
|
switch (name) {
|
|
29
26
|
case 'label':
|
|
30
27
|
{
|