@nectary/components 0.43.0 → 0.44.1
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 +3 -3
- package/color-menu/index.js +2 -2
- package/date-picker/index.js +173 -64
- package/date-picker/types.d.ts +6 -0
- package/date-picker/utils.d.ts +6 -3
- package/date-picker/utils.js +19 -4
- package/emoji-picker/data.json +1 -0
- package/file-drop/types.d.ts +2 -2
- package/file-picker/types.d.ts +1 -1
- package/package.json +4 -4
- package/segmented-icon-control/index.js +3 -3
- package/select-menu/index.js +3 -3
- package/stop-events/index.js +3 -3
- package/tile-control/index.js +3 -3
- package/utils/csv.d.ts +4 -2
- package/utils/csv.js +14 -13
package/file-drop/types.d.ts
CHANGED
|
@@ -44,7 +44,7 @@ export declare type TSinchFileDropReact = TSinchElementReact<TSinchFileDropEleme
|
|
|
44
44
|
/** Placeholder */
|
|
45
45
|
placeholder: string;
|
|
46
46
|
/** Change value handler */
|
|
47
|
-
'on-change'
|
|
47
|
+
'on-change': (e: CustomEvent<File[]>) => void;
|
|
48
48
|
/** Invalid handler */
|
|
49
|
-
'on-invalid'
|
|
49
|
+
'on-invalid': (e: CustomEvent<TSinchFileDropInvalidType>) => void;
|
|
50
50
|
};
|
package/file-picker/types.d.ts
CHANGED
|
@@ -28,5 +28,5 @@ export declare type TSinchFilePickerReact = TSinchElementReact<TSinchFilePickerE
|
|
|
28
28
|
/** Change value handler */
|
|
29
29
|
'on-change': (e: CustomEvent<File[]>) => void;
|
|
30
30
|
/** Invalid handler */
|
|
31
|
-
'on-invalid'
|
|
31
|
+
'on-invalid': (e: CustomEvent<TSinchFilePickerInvalidType>) => void;
|
|
32
32
|
};
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nectary/components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.44.1",
|
|
4
4
|
"files": [
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"theme/*.json",
|
|
5
|
+
"**/*/*.css",
|
|
6
|
+
"**/*/*.json",
|
|
8
7
|
"**/*/*.js",
|
|
9
8
|
"**/*/*.d.ts",
|
|
9
|
+
"theme.css",
|
|
10
10
|
"types.d.ts",
|
|
11
11
|
"colors.json"
|
|
12
12
|
],
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineCustomElement, getAttribute, getBooleanAttribute,
|
|
1
|
+
import { defineCustomElement, getAttribute, getBooleanAttribute, unpackCsv, getFirstCsvValue, getReactEventHandler, NectaryElement, updateAttribute, updateBooleanAttribute, updateCsv } from '../utils';
|
|
2
2
|
const templateHTML = '<style>:host{display:block;outline:0}#wrapper{display:flex;flex-direction:row}</style><div id="wrapper"><slot></slot></div>';
|
|
3
3
|
const template = document.createElement('template');
|
|
4
4
|
template.innerHTML = templateHTML;
|
|
@@ -69,9 +69,9 @@ defineCustomElement('sinch-segmented-icon-control', class extends NectaryElement
|
|
|
69
69
|
};
|
|
70
70
|
#onValueChange(csv) {
|
|
71
71
|
if (this.multiple) {
|
|
72
|
-
const values =
|
|
72
|
+
const values = unpackCsv(csv);
|
|
73
73
|
for (const $option of this.#$slot.assignedElements()) {
|
|
74
|
-
const isChecked = !getBooleanAttribute($option, 'disabled') && values.
|
|
74
|
+
const isChecked = !getBooleanAttribute($option, 'disabled') && values.includes(getAttribute($option, 'value', ''));
|
|
75
75
|
updateBooleanAttribute($option, 'data-checked', isChecked);
|
|
76
76
|
}
|
|
77
77
|
} else {
|
package/select-menu/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { attrValueToPixels, defineCustomElement, dispatchContextConnectEvent, dispatchContextDisconnectEvent, getAttribute, getBooleanAttribute,
|
|
1
|
+
import { attrValueToPixels, defineCustomElement, dispatchContextConnectEvent, dispatchContextDisconnectEvent, getAttribute, getBooleanAttribute, unpackCsv, getFirstCsvValue, getIntegerAttribute, getReactEventHandler, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateCsv, updateExplicitBooleanAttribute, updateIntegerAttribute } from '../utils';
|
|
2
2
|
const templateHTML = '<style>:host{display:block;outline:0}#listbox{overflow-y:auto}</style><div id="listbox" role="presentation"><slot></slot></div>';
|
|
3
3
|
const ITEM_HEIGHT = 40;
|
|
4
4
|
const template = document.createElement('template');
|
|
@@ -159,9 +159,9 @@ defineCustomElement('sinch-select-menu', class extends NectaryElement {
|
|
|
159
159
|
};
|
|
160
160
|
#onValueChange(csv) {
|
|
161
161
|
if (this.multiple) {
|
|
162
|
-
const values =
|
|
162
|
+
const values = unpackCsv(csv);
|
|
163
163
|
for (const $option of this.#getOptionElements()) {
|
|
164
|
-
const isChecked = !getBooleanAttribute($option, 'disabled') && values.
|
|
164
|
+
const isChecked = !getBooleanAttribute($option, 'disabled') && values.includes(getAttribute($option, 'value', ''));
|
|
165
165
|
updateBooleanAttribute($option, 'data-checked', isChecked);
|
|
166
166
|
}
|
|
167
167
|
} else {
|
package/stop-events/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { defineCustomElement,
|
|
1
|
+
import { defineCustomElement, unpackCsv } from '../utils';
|
|
2
2
|
defineCustomElement('sinch-stop-events', class extends HTMLElement {
|
|
3
3
|
constructor() {
|
|
4
4
|
super();
|
|
5
5
|
this.style.display = 'contents';
|
|
6
6
|
}
|
|
7
7
|
connectedCallback() {
|
|
8
|
-
const events =
|
|
8
|
+
const events = unpackCsv(this.getAttribute('events'));
|
|
9
9
|
for (const event of events) {
|
|
10
10
|
this.addEventListener(event, this.#stopEvent);
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
disconnectedCallback() {
|
|
14
|
-
const events =
|
|
14
|
+
const events = unpackCsv(this.getAttribute('events'));
|
|
15
15
|
for (const event of events) {
|
|
16
16
|
this.removeEventListener(event, this.#stopEvent);
|
|
17
17
|
}
|
package/tile-control/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineCustomElement, getAttribute, getBooleanAttribute,
|
|
1
|
+
import { defineCustomElement, getAttribute, getBooleanAttribute, unpackCsv, getFirstCsvValue, getIntegerAttribute, getReactEventHandler, NectaryElement, updateAttribute, updateBooleanAttribute, updateCsv, updateIntegerAttribute } from '../utils';
|
|
2
2
|
const templateHTML = '<style>:host{display:block;outline:0;--sinch-grid-num-columns:1}#wrapper{display:grid;grid-template-columns:repeat(var(--sinch-grid-num-columns),auto);gap:16px;width:fit-content}:host([small]:not([small=false])) #wrapper{gap:8px}:host([cols="2"]){--sinch-grid-num-columns:2}:host([cols="3"]){--sinch-grid-num-columns:3}:host([cols="4"]){--sinch-grid-num-columns:4}:host([cols="5"]){--sinch-grid-num-columns:5}:host([cols="6"]){--sinch-grid-num-columns:6}:host([cols="7"]){--sinch-grid-num-columns:7}:host([cols="8"]){--sinch-grid-num-columns:8}</style><div id="wrapper"><slot></slot></div>';
|
|
3
3
|
const template = document.createElement('template');
|
|
4
4
|
template.innerHTML = templateHTML;
|
|
@@ -91,9 +91,9 @@ defineCustomElement('sinch-tile-control', class extends NectaryElement {
|
|
|
91
91
|
};
|
|
92
92
|
#onValueChange(csv) {
|
|
93
93
|
if (this.multiple) {
|
|
94
|
-
const values =
|
|
94
|
+
const values = unpackCsv(csv);
|
|
95
95
|
for (const $option of this.#$slot.assignedElements()) {
|
|
96
|
-
const isChecked = !getBooleanAttribute($option, 'disabled') && values.
|
|
96
|
+
const isChecked = !getBooleanAttribute($option, 'disabled') && values.includes(getAttribute($option, 'value', ''));
|
|
97
97
|
updateBooleanAttribute($option, 'data-checked', isChecked);
|
|
98
98
|
}
|
|
99
99
|
} else {
|
package/utils/csv.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
export declare const
|
|
2
|
-
export declare const
|
|
1
|
+
export declare const CSV_DELIMITER = ",";
|
|
2
|
+
export declare const packCsv: (values: string[]) => string;
|
|
3
|
+
export declare const unpackCsv: (csv: string) => string[];
|
|
4
|
+
export declare const updateCsv: (csv: string, value: string, setActive: boolean) => string;
|
|
3
5
|
export declare const getFirstCsvValue: (acc: string) => string | null;
|
package/utils/csv.js
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
1
|
+
export const CSV_DELIMITER = ',';
|
|
2
|
+
export const packCsv = values => {
|
|
3
|
+
return values.join(CSV_DELIMITER);
|
|
3
4
|
};
|
|
4
|
-
const
|
|
5
|
-
return
|
|
5
|
+
export const unpackCsv = csv => {
|
|
6
|
+
return csv.length === 0 ? [] : csv.split(CSV_DELIMITER);
|
|
6
7
|
};
|
|
7
|
-
export const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export const updateCsv = (acc, value, setActive) => {
|
|
11
|
-
const values = getCsvSet(acc);
|
|
8
|
+
export const updateCsv = (csv, value, setActive) => {
|
|
9
|
+
const values = unpackCsv(csv);
|
|
10
|
+
const index = values.indexOf(value);
|
|
12
11
|
if (setActive) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
if (index < 0) {
|
|
13
|
+
values.push(value);
|
|
14
|
+
}
|
|
15
|
+
} else if (index >= 0) {
|
|
16
|
+
values.splice(index, 1);
|
|
16
17
|
}
|
|
17
18
|
return packCsv(values);
|
|
18
19
|
};
|
|
19
20
|
export const getFirstCsvValue = acc => {
|
|
20
|
-
return acc ===
|
|
21
|
+
return acc.length === 0 ? null : unpackCsv(acc)[0];
|
|
21
22
|
};
|