@nectary/components 5.49.0 → 5.50.0
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/bundle.js +29 -13
- package/color-menu/index.js +10 -4
- package/color-menu-option/index.js +1 -1
- package/emoji-picker/index.js +1 -1
- package/field-v2/index.d.ts +2 -0
- package/field-v2/index.js +15 -5
- package/field-v2/types.d.ts +3 -0
- package/package.json +3 -3
package/color-menu/index.js
CHANGED
|
@@ -6,8 +6,9 @@ import { getReactEventHandler } from "../utils/get-react-event-handler.js";
|
|
|
6
6
|
import { getTargetByAttribute } from "../utils/event-target.js";
|
|
7
7
|
const templateHTML = '<style>:host{display:block;outline:0}#listbox{display:flex;flex-direction:row;flex-wrap:wrap;padding:4px 10px;overflow-y:auto}#listbox.empty{display:none}</style><div id="listbox" role="presentation"><slot id="options"></slot></div>';
|
|
8
8
|
const NUM_COLS_DEFAULT = 5;
|
|
9
|
-
const
|
|
10
|
-
const
|
|
9
|
+
const ICON_SIZE_DEFAULT = 32;
|
|
10
|
+
const ITEM_HORIZONTAL_PADDING = 12;
|
|
11
|
+
const ITEM_VERTICAL_PADDING = 24;
|
|
11
12
|
const template = document.createElement("template");
|
|
12
13
|
template.innerHTML = templateHTML;
|
|
13
14
|
class ColorMenu extends NectaryElement {
|
|
@@ -100,16 +101,21 @@ class ColorMenu extends NectaryElement {
|
|
|
100
101
|
return null;
|
|
101
102
|
}
|
|
102
103
|
#onSlotChange = () => {
|
|
104
|
+
this.#updateRows();
|
|
103
105
|
this.#updateColumns();
|
|
104
106
|
this.#onValueChange();
|
|
105
107
|
};
|
|
108
|
+
#getIconSize() {
|
|
109
|
+
const size = parseFloat(getComputedStyle(this).getPropertyValue("--sinch-global-size-icon"));
|
|
110
|
+
return Number.isNaN(size) ? ICON_SIZE_DEFAULT : size;
|
|
111
|
+
}
|
|
106
112
|
#updateRows() {
|
|
107
113
|
const rowsValue = getAttribute(this, "rows");
|
|
108
114
|
this.#$listbox.style.maxHeight = attrValueToPixels(
|
|
109
115
|
rowsValue,
|
|
110
116
|
{
|
|
111
117
|
min: 2,
|
|
112
|
-
itemSizeMultiplier:
|
|
118
|
+
itemSizeMultiplier: this.#getIconSize() + ITEM_VERTICAL_PADDING
|
|
113
119
|
}
|
|
114
120
|
);
|
|
115
121
|
}
|
|
@@ -122,7 +128,7 @@ class ColorMenu extends NectaryElement {
|
|
|
122
128
|
min: 1,
|
|
123
129
|
max: numItems,
|
|
124
130
|
defaultValue: Math.min(numItems, NUM_COLS_DEFAULT),
|
|
125
|
-
itemSizeMultiplier:
|
|
131
|
+
itemSizeMultiplier: this.#getIconSize() + ITEM_HORIZONTAL_PADDING
|
|
126
132
|
}
|
|
127
133
|
);
|
|
128
134
|
}
|
|
@@ -3,7 +3,7 @@ import "../tooltip/index.js";
|
|
|
3
3
|
import { isSwatchColor, getSwatchColorFg } from "../color-swatch/utils.js";
|
|
4
4
|
import { updateAttribute, getAttribute } from "../utils/dom.js";
|
|
5
5
|
import { defineCustomElement, NectaryElement } from "../utils/element.js";
|
|
6
|
-
const templateHTML = '<style>:host{display:block;outline:0}#wrapper{width:calc(var(--sinch-global-size-icon,32px) + 12px);height:calc(var(--sinch-global-size-icon,32px) + 24px);padding:12px 6px;box-sizing:border-box}#swatch-wrapper{position:relative;cursor:pointer;width:var(--sinch-global-size-icon,32px);height:var(--sinch-global-size-icon,32px)}#swatch-wrapper::after{content:"";position:absolute;width:calc(var(--sinch-global-size-icon,32px) + 2px);height:calc(var(--sinch-global-size-icon,32px) + 2px);inset:-3px;border:2px solid var(--sinch-comp-color-menu-option-color-default-border-initial);border-radius:50%;pointer-events:none}:host([data-checked]) #swatch-wrapper::after{border-color:var(--sinch-comp-color-menu-option-color-default-border-selected)}:host([data-selected]) #swatch-wrapper::after{border-color:var(--sinch-comp-color-menu-option-color-default-border-focus)}:host(:hover) #swatch-wrapper::after{border-color:var(--sinch-comp-color-menu-option-color-default-border-hover)}:host(:active) #swatch-wrapper::after{border-color:var(--sinch-comp-color-menu-option-color-default-border-active)}</style><div id="wrapper"><sinch-tooltip id="tooltip"><div id="swatch-wrapper"><sinch-color-swatch id="swatch"></sinch-color-swatch></div></sinch-tooltip></div>';
|
|
6
|
+
const templateHTML = '<style>:host{display:block;outline:0}#wrapper{width:calc(var(--sinch-global-size-icon,32px) + 12px);height:calc(var(--sinch-global-size-icon,32px) + 24px);padding:12px 6px;box-sizing:border-box}#swatch-wrapper{position:relative;cursor:pointer;width:var(--sinch-global-size-icon,32px);height:var(--sinch-global-size-icon,32px)}#swatch{display:block}#swatch-wrapper::after{content:"";position:absolute;width:calc(var(--sinch-global-size-icon,32px) + 2px);height:calc(var(--sinch-global-size-icon,32px) + 2px);inset:-3px;border:2px solid var(--sinch-comp-color-menu-option-color-default-border-initial);border-radius:50%;pointer-events:none}:host([data-checked]) #swatch-wrapper::after{border-color:var(--sinch-comp-color-menu-option-color-default-border-selected)}:host([data-selected]) #swatch-wrapper::after{border-color:var(--sinch-comp-color-menu-option-color-default-border-focus)}:host(:hover) #swatch-wrapper::after{border-color:var(--sinch-comp-color-menu-option-color-default-border-hover)}:host(:active) #swatch-wrapper::after{border-color:var(--sinch-comp-color-menu-option-color-default-border-active)}</style><div id="wrapper"><sinch-tooltip id="tooltip"><div id="swatch-wrapper"><sinch-color-swatch id="swatch"></sinch-color-swatch></div></sinch-tooltip></div>';
|
|
7
7
|
const template = document.createElement("template");
|
|
8
8
|
template.innerHTML = templateHTML;
|
|
9
9
|
class ColorMenuOption extends NectaryElement {
|