@nectary/components 4.10.2 → 4.10.4
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/avatar/index.js +1 -1
- package/package.json +3 -3
- package/radio/index.js +24 -10
- package/radio-option/types.d.ts +11 -3
package/avatar/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineCustomElement, getAttribute, getLiteralAttribute, NectaryElement, updateAttribute, updateLiteralAttribute } from '../utils';
|
|
2
2
|
import { DEFAULT_SIZE, sizeValues } from '../utils/size';
|
|
3
|
-
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#wrapper{position:relative;width:var(--sinch-local-size);height:var(--sinch-local-size);border-radius:var(--sinch-comp-avatar-shape-radius);--sinch-local-size:var(--sinch-comp-avatar-size-m)}:host([size="l"]) #wrapper{--sinch-local-size:var(--sinch-comp-avatar-size-l)}:host([size="s"]) #wrapper{--sinch-local-size:var(--sinch-comp-avatar-size-s)}#text{display:block;width:100%;height:100%;font:var(--sinch-comp-avatar-container-font-size-m-text);line-height:calc(var(--sinch-local-size) - 2px);text-transform:uppercase;text-align:center}:host([size="l"]) #text{font:var(--sinch-comp-avatar-container-font-size-l-text);line-height:calc(var(--sinch-local-size) - 2px)}:host([size="s"]) #text{font:var(--sinch-comp-avatar-container-font-size-s-text);line-height:calc(var(--sinch-local-size) - 2px)}#circle{position:relative;width:calc(100% - 2px);height:calc(100% - 2px);left:1px;top:1px;border-radius:50%;-webkit-mask:linear-gradient(#fff,#000);mask:linear-gradient(#fff,#000);background-color:var(--sinch-comp-avatar-container-color-default-background);color:var(--sinch-comp-avatar-container-color-default-foreground)}#image{display:none;position:absolute;left:0;top:0;width:100%;height:100%;object-fit:contain}:host([src]:not([src=""])) #image{display:block}#person{display:none;position:absolute;left:0;top:0;width:100%;height:100%;fill:var(--sinch-comp-avatar-container-color-default-foreground)
|
|
3
|
+
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#wrapper{position:relative;width:var(--sinch-local-size);height:var(--sinch-local-size);border-radius:var(--sinch-comp-avatar-shape-radius);--sinch-local-size:var(--sinch-comp-avatar-size-m)}:host([size="l"]) #wrapper{--sinch-local-size:var(--sinch-comp-avatar-size-l)}:host([size="s"]) #wrapper{--sinch-local-size:var(--sinch-comp-avatar-size-s)}#text{display:block;width:100%;height:100%;font:var(--sinch-comp-avatar-container-font-size-m-text);line-height:calc(var(--sinch-local-size) - 2px);text-transform:uppercase;text-align:center}:host([size="l"]) #text{font:var(--sinch-comp-avatar-container-font-size-l-text);line-height:calc(var(--sinch-local-size) - 2px)}:host([size="s"]) #text{font:var(--sinch-comp-avatar-container-font-size-s-text);line-height:calc(var(--sinch-local-size) - 2px)}#circle{position:relative;width:calc(100% - 2px);height:calc(100% - 2px);left:1px;top:1px;border-radius:50%;-webkit-mask:linear-gradient(#fff,#000);mask:linear-gradient(#fff,#000);background-color:var(--sinch-comp-avatar-container-color-default-background);color:var(--sinch-comp-avatar-container-color-default-foreground)}#image{display:none;position:absolute;left:0;top:0;width:100%;height:100%;object-fit:contain}:host([src]:not([src=""])) #image{display:block}#person{display:none;position:absolute;left:0;top:0;width:100%;height:100%;fill:var(--sinch-comp-avatar-container-color-default-foreground)}:host(:not([src]):is(:not([alt]),[alt=""])) #person{display:block}#status-wrapper{position:absolute;left:calc(85% - 5px);top:calc(85% - 5px);width:10px;height:10px;padding:1px;box-sizing:border-box;border-radius:50%;background-color:var(--sinch-comp-avatar-status-color-border);display:none;pointer-events:none}#status{width:8px;height:8px;border-radius:50%}:host([status=away]) #status-wrapper,:host([status=busy]) #status-wrapper,:host([status=offline]) #status-wrapper,:host([status=online]) #status-wrapper{display:block}:host([status=online]) #status{background-color:var(--sinch-comp-avatar-status-color-online-default-background)}:host([status=away]) #status{background-color:var(--sinch-comp-avatar-status-color-away-default-background)}:host([status=busy]) #status{background-color:var(--sinch-comp-avatar-status-color-busy-default-background)}:host([status=offline]) #status{background-color:var(--sinch-comp-avatar-status-color-offline-default-background)}</style><div id="wrapper"><div id="circle"><span id="text"></span><img id="image" alt=""/><svg id="person" viewBox="0 0 40 40" fill="none"><path d="M29.451 15.785a9.451 9.451 0 1 1-18.902 0 9.452 9.452 0 0 1 18.902 0ZM4.734 40.5c.119-7.085 5.899-12.792 13.012-12.792h4.508c7.113 0 12.893 5.707 13.012 12.792H4.734Z"/></svg></div><div id="status-wrapper"><div id="status"></div></div></div>';
|
|
4
4
|
import { getAvatarColorBg, getAvatarColorFg, statusValues } from './utils';
|
|
5
5
|
const template = document.createElement('template');
|
|
6
6
|
template.innerHTML = templateHTML;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nectary/components",
|
|
3
|
-
"version": "4.10.
|
|
3
|
+
"version": "4.10.4",
|
|
4
4
|
"files": [
|
|
5
5
|
"**/*/*.css",
|
|
6
6
|
"**/*/*.json",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@babel/runtime": "^7.22.15",
|
|
23
|
-
"@nectary/assets": "2.4.
|
|
23
|
+
"@nectary/assets": "2.4.2"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@babel/cli": "^7.22.15",
|
|
@@ -34,6 +34,6 @@
|
|
|
34
34
|
"typescript": "^5.2.2"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"@nectary/theme-base": "1.4.
|
|
37
|
+
"@nectary/theme-base": "1.4.4"
|
|
38
38
|
}
|
|
39
39
|
}
|
package/radio/index.js
CHANGED
|
@@ -129,22 +129,33 @@ defineCustomElement('sinch-radio', class extends NectaryElement {
|
|
|
129
129
|
}));
|
|
130
130
|
};
|
|
131
131
|
#onValueChange(value) {
|
|
132
|
-
for (const
|
|
133
|
-
const
|
|
134
|
-
|
|
132
|
+
for (const node of this.#$slot.assignedElements()) {
|
|
133
|
+
const $option = this.#findRadioOptionElement(node);
|
|
134
|
+
if ($option != null) {
|
|
135
|
+
const isChecked = value === getAttribute($option, 'value', '');
|
|
136
|
+
updateBooleanAttribute($option, 'checked', isChecked);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
#findRadioOptionElement(node) {
|
|
141
|
+
if (node.tagName === 'SINCH-RADIO-OPTION') {
|
|
142
|
+
return node;
|
|
135
143
|
}
|
|
144
|
+
return node.querySelector?.('sinch-radio-option') ?? null;
|
|
136
145
|
}
|
|
137
146
|
#getFirstOption() {
|
|
138
|
-
for (const
|
|
139
|
-
|
|
147
|
+
for (const node of this.#$slot.assignedElements()) {
|
|
148
|
+
const $option = this.#findRadioOptionElement(node);
|
|
149
|
+
if ($option?.disabled !== true) {
|
|
140
150
|
return $option;
|
|
141
151
|
}
|
|
142
152
|
}
|
|
143
153
|
return null;
|
|
144
154
|
}
|
|
145
155
|
#getLastOption() {
|
|
146
|
-
for (const
|
|
147
|
-
|
|
156
|
+
for (const node of this.#$slot.assignedElements().reverse()) {
|
|
157
|
+
const $option = this.#findRadioOptionElement(node);
|
|
158
|
+
if ($option?.disabled !== true) {
|
|
148
159
|
return $option;
|
|
149
160
|
}
|
|
150
161
|
}
|
|
@@ -169,14 +180,17 @@ defineCustomElement('sinch-radio', class extends NectaryElement {
|
|
|
169
180
|
return $options[(currentIndex - 1 + $options.length) % $options.length];
|
|
170
181
|
}
|
|
171
182
|
#getEnabledRadioElements() {
|
|
172
|
-
return this.#$slot.assignedElements().filter(el => !el.hasAttribute('disabled'));
|
|
183
|
+
return this.#$slot.assignedElements().map(el => this.#findRadioOptionElement(el)).filter(Boolean).filter(el => !el.hasAttribute('disabled'));
|
|
173
184
|
}
|
|
174
185
|
#findSelectedOption(elements) {
|
|
175
186
|
return elements.find(el => el.checked) ?? null;
|
|
176
187
|
}
|
|
177
188
|
#updateInvalid(isInvalid) {
|
|
178
|
-
for (const
|
|
179
|
-
|
|
189
|
+
for (const node of this.#$slot.assignedElements()) {
|
|
190
|
+
const $option = this.#findRadioOptionElement(node);
|
|
191
|
+
if ($option != null) {
|
|
192
|
+
updateBooleanAttribute($option, 'data-invalid', isInvalid);
|
|
193
|
+
}
|
|
180
194
|
}
|
|
181
195
|
}
|
|
182
196
|
#onChangeReactHandler = e => {
|
package/radio-option/types.d.ts
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
import type { NectaryComponentReactByType, NectaryComponentVanillaByType } from '../types';
|
|
2
|
-
export type TSinchRadioOptionProps = {
|
|
2
|
+
export type TSinchRadioOptionProps = ({
|
|
3
3
|
value: string;
|
|
4
4
|
checked?: boolean;
|
|
5
5
|
disabled?: boolean;
|
|
6
|
-
text
|
|
6
|
+
text?: string;
|
|
7
7
|
'aria-label': string;
|
|
8
|
-
|
|
8
|
+
'aria-labelledby'?: never;
|
|
9
|
+
}) | ({
|
|
10
|
+
value: string;
|
|
11
|
+
checked?: boolean;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
text?: string;
|
|
14
|
+
'aria-label'?: never;
|
|
15
|
+
'aria-labelledby': string;
|
|
16
|
+
});
|
|
9
17
|
export type TSinchRadioOptionStyle = {
|
|
10
18
|
'--sinch-comp-radio-color-default-background-initial'?: string;
|
|
11
19
|
'--sinch-comp-radio-color-default-background-hover'?: string;
|