@waggylabs/yumekit 0.2.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/dist/components/y-appbar.d.ts +28 -0
- package/dist/components/y-appbar.js +1707 -0
- package/dist/components/y-avatar.d.ts +5 -0
- package/dist/components/y-avatar.js +108 -0
- package/dist/components/y-badge.d.ts +15 -0
- package/dist/components/y-badge.js +149 -0
- package/dist/components/y-button.d.ts +19 -0
- package/dist/components/y-button.js +557 -0
- package/dist/components/y-card.d.ts +8 -0
- package/dist/components/y-card.js +157 -0
- package/dist/components/y-checkbox.d.ts +20 -0
- package/dist/components/y-checkbox.js +256 -0
- package/dist/components/y-dialog.d.ts +18 -0
- package/dist/components/y-dialog.js +232 -0
- package/dist/components/y-drawer.d.ts +1 -0
- package/dist/components/y-drawer.js +459 -0
- package/dist/components/y-icon.d.ts +19 -0
- package/dist/components/y-icon.js +270 -0
- package/dist/components/y-input.d.ts +15 -0
- package/dist/components/y-input.js +233 -0
- package/dist/components/y-menu.d.ts +26 -0
- package/dist/components/y-menu.js +322 -0
- package/dist/components/y-panel.d.ts +23 -0
- package/dist/components/y-panel.js +366 -0
- package/dist/components/y-panelbar.d.ts +3 -0
- package/dist/components/y-panelbar.js +27 -0
- package/dist/components/y-progress.d.ts +38 -0
- package/dist/components/y-progress.js +328 -0
- package/dist/components/y-radio.d.ts +16 -0
- package/dist/components/y-radio.js +202 -0
- package/dist/components/y-select.d.ts +33 -0
- package/dist/components/y-select.js +524 -0
- package/dist/components/y-slider.d.ts +34 -0
- package/dist/components/y-slider.js +387 -0
- package/dist/components/y-switch.d.ts +24 -0
- package/dist/components/y-switch.js +373 -0
- package/dist/components/y-table.d.ts +25 -0
- package/dist/components/y-table.js +327 -0
- package/dist/components/y-tabs.d.ts +21 -0
- package/dist/components/y-tabs.js +286 -0
- package/dist/components/y-tag.d.ts +7 -0
- package/dist/components/y-tag.js +218 -0
- package/dist/components/y-theme.d.ts +10 -0
- package/dist/components/y-theme.js +115 -0
- package/dist/components/y-toast.d.ts +33 -0
- package/dist/components/y-toast.js +248 -0
- package/dist/components/y-tooltip.d.ts +25 -0
- package/dist/components/y-tooltip.js +228 -0
- package/dist/icons/all.d.ts +1 -0
- package/dist/icons/all.js +208 -0
- package/dist/icons/index.d.ts +19 -0
- package/dist/icons/registry.d.ts +3 -0
- package/dist/icons/registry.js +30 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.iife.d.ts +1 -0
- package/dist/index.js +7137 -0
- package/dist/modules/helpers.d.ts +44 -0
- package/dist/modules/helpers.js +124 -0
- package/dist/react.d.ts +214 -0
- package/dist/styles/blue-dark.css +138 -0
- package/dist/styles/blue-light.css +138 -0
- package/dist/styles/orange-dark.css +138 -0
- package/dist/styles/orange-light.css +138 -0
- package/dist/styles/style.css +8 -0
- package/dist/styles/variables.css +594 -0
- package/dist/yumekit.min.js +1 -0
- package/package.json +55 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { getColorVarPair } from '../modules/helpers.js';
|
|
2
|
+
|
|
3
|
+
class YumeAvatar extends HTMLElement {
|
|
4
|
+
static get observedAttributes() {
|
|
5
|
+
return ["src", "alt", "size", "shape", "color"];
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
constructor() {
|
|
9
|
+
super();
|
|
10
|
+
this.attachShadow({ mode: "open" });
|
|
11
|
+
this.render();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
15
|
+
if (oldValue !== newValue) {
|
|
16
|
+
this.render();
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
render() {
|
|
21
|
+
const src = this.getAttribute("src");
|
|
22
|
+
const altRaw = this.getAttribute("alt") || "AN";
|
|
23
|
+
const shape = this.getAttribute("shape") || "circle";
|
|
24
|
+
const color = this.getAttribute("color") || "primary";
|
|
25
|
+
const borderRadius = `var(--component-avatar-border-radius-${shape}, 9999px)`;
|
|
26
|
+
const [bgColor, textColor] = getColorVarPair(color);
|
|
27
|
+
|
|
28
|
+
let dimensions;
|
|
29
|
+
const size = this.getAttribute("size") || "medium";
|
|
30
|
+
|
|
31
|
+
switch (size) {
|
|
32
|
+
case "small":
|
|
33
|
+
dimensions = "var(--component-avatar-size-small, 27px)";
|
|
34
|
+
break;
|
|
35
|
+
case "large":
|
|
36
|
+
dimensions = "var(--component-avatar-size-large, 51px)";
|
|
37
|
+
break;
|
|
38
|
+
case "medium":
|
|
39
|
+
default:
|
|
40
|
+
dimensions = "var(--component-avatar-size-medium, 35px)";
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const componentSheet = new CSSStyleSheet();
|
|
45
|
+
let componentStyles = "";
|
|
46
|
+
|
|
47
|
+
if (src) {
|
|
48
|
+
componentStyles = `
|
|
49
|
+
:host {
|
|
50
|
+
display: inline-block;
|
|
51
|
+
height: ${dimensions};
|
|
52
|
+
min-width: ${dimensions};
|
|
53
|
+
}
|
|
54
|
+
img {
|
|
55
|
+
width: 100%;
|
|
56
|
+
height: 100%;
|
|
57
|
+
object-fit: cover;
|
|
58
|
+
border-radius: ${borderRadius};
|
|
59
|
+
}
|
|
60
|
+
`;
|
|
61
|
+
} else {
|
|
62
|
+
componentStyles = `
|
|
63
|
+
:host {
|
|
64
|
+
display: inline-block;
|
|
65
|
+
width: ${dimensions};
|
|
66
|
+
height: ${dimensions};
|
|
67
|
+
min-width: ${dimensions};
|
|
68
|
+
font-family: var(--font-family-header, "Lexend"), sans-serif;
|
|
69
|
+
text-transform: uppercase;
|
|
70
|
+
}
|
|
71
|
+
.avatar {
|
|
72
|
+
width: 100%;
|
|
73
|
+
height: 100%;
|
|
74
|
+
border-radius: ${borderRadius};
|
|
75
|
+
background-color: ${bgColor};
|
|
76
|
+
color: ${textColor};
|
|
77
|
+
display: flex;
|
|
78
|
+
align-items: center;
|
|
79
|
+
justify-content: center;
|
|
80
|
+
}
|
|
81
|
+
.avatar h5 {
|
|
82
|
+
margin: 0;
|
|
83
|
+
font-size: calc(${dimensions} * 0.5);
|
|
84
|
+
}
|
|
85
|
+
`;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
componentSheet.replaceSync(componentStyles);
|
|
89
|
+
this.shadowRoot.adoptedStyleSheets = [componentSheet];
|
|
90
|
+
|
|
91
|
+
if (src) {
|
|
92
|
+
this.shadowRoot.innerHTML = `<img src="${src}" alt="${altRaw}" part="avatar" />`;
|
|
93
|
+
} else {
|
|
94
|
+
const words = altRaw.trim().split(/\s+/);
|
|
95
|
+
const displayText =
|
|
96
|
+
words.length >= 2
|
|
97
|
+
? words[0].charAt(0) + words[1].charAt(0)
|
|
98
|
+
: altRaw.substring(0, 2);
|
|
99
|
+
this.shadowRoot.innerHTML = `<div class="avatar" part="avatar"><h5>${displayText}</h5></div>`;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (!customElements.get("y-avatar")) {
|
|
105
|
+
customElements.define("y-avatar", YumeAvatar);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export { YumeAvatar };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export class YumeBadge extends HTMLElement {
|
|
2
|
+
static get observedAttributes(): string[];
|
|
3
|
+
connectedCallback(): void;
|
|
4
|
+
attributeChangedCallback(name: any, oldValue: any, newValue: any): void;
|
|
5
|
+
get alignment(): string;
|
|
6
|
+
get color(): string;
|
|
7
|
+
get position(): string;
|
|
8
|
+
get size(): string;
|
|
9
|
+
get value(): string;
|
|
10
|
+
getBadgeColors(color: any): any;
|
|
11
|
+
getBadgePosition(position: any, alignment: any): string;
|
|
12
|
+
getSizeAttributes(size: any): any;
|
|
13
|
+
hasTargetContent(): boolean;
|
|
14
|
+
render(): void;
|
|
15
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
class YumeBadge extends HTMLElement {
|
|
2
|
+
static get observedAttributes() {
|
|
3
|
+
return ["value", "position", "alignment", "color", "size"];
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
constructor() {
|
|
7
|
+
super();
|
|
8
|
+
this.attachShadow({ mode: "open" });
|
|
9
|
+
this.render();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
connectedCallback() {
|
|
13
|
+
this.render();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
17
|
+
if (oldValue !== newValue) {
|
|
18
|
+
this.render();
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
get alignment() {
|
|
23
|
+
return this.getAttribute("alignment") || "right";
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
get color() {
|
|
27
|
+
return this.getAttribute("color") || "primary";
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
get position() {
|
|
31
|
+
return this.getAttribute("position") || "top";
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
get size() {
|
|
35
|
+
return this.getAttribute("size") || "small";
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
get value() {
|
|
39
|
+
return this.getAttribute("value") || "";
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
getBadgeColors(color) {
|
|
43
|
+
const colorMap = {
|
|
44
|
+
primary: ["var(--primary-content--)", "var(--primary-content-inverse)"],
|
|
45
|
+
secondary: ["var(--secondary-content--)", "var(--secondary-content-inverse)"],
|
|
46
|
+
base: ["var(--base-content--)", "var(--base-content-inverse)"],
|
|
47
|
+
success: ["var(--success-content--)", "var(--success-content-inverse)"],
|
|
48
|
+
warning: ["var(--warning-content--)", "var(--warning-content-inverse)"],
|
|
49
|
+
error: ["var(--error-content--)", "var(--error-content-inverse)"],
|
|
50
|
+
help: ["var(--help-content--)", "var(--help-content-inverse)"],
|
|
51
|
+
};
|
|
52
|
+
return colorMap[color] || [color, "var(--neutral-white, #fff)"];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
getBadgePosition(position, alignment) {
|
|
56
|
+
const offset = "var(--spacing-small, 6px)";
|
|
57
|
+
const vertical =
|
|
58
|
+
position === "top"
|
|
59
|
+
? `top: calc(${offset} * -1);`
|
|
60
|
+
: `bottom: calc(${offset} * -1);`;
|
|
61
|
+
const horizontal =
|
|
62
|
+
alignment === "right"
|
|
63
|
+
? `right: calc(${offset} * -1);`
|
|
64
|
+
: `left: calc(${offset} * -1);`;
|
|
65
|
+
return `${vertical} ${horizontal}`;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
getSizeAttributes(size) {
|
|
69
|
+
const sizeMap = {
|
|
70
|
+
small: {
|
|
71
|
+
fontSize: "var(--font-size-small, 0.8em)",
|
|
72
|
+
padding: "var(--component-badge-padding-small)",
|
|
73
|
+
minSize: "var(--component-badge-size-small)",
|
|
74
|
+
},
|
|
75
|
+
medium: {
|
|
76
|
+
fontSize: "var(--font-size-label, 0.83em)",
|
|
77
|
+
padding: "var(--component-badge-padding-medium)",
|
|
78
|
+
minSize: "var(--component-badge-size-medium)",
|
|
79
|
+
},
|
|
80
|
+
large: {
|
|
81
|
+
fontSize: "var(--font-size-paragraph, 1em)",
|
|
82
|
+
padding: "var(--component-badge-padding-large)",
|
|
83
|
+
minSize: "var(--component-badge-size-large)",
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
return sizeMap[size] || sizeMap.small;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
hasTargetContent() {
|
|
90
|
+
return Array.from(this.childNodes).some((node) => {
|
|
91
|
+
if (node.nodeType === Node.ELEMENT_NODE) return true;
|
|
92
|
+
if (node.nodeType === Node.TEXT_NODE) {
|
|
93
|
+
return node.textContent.trim() !== "";
|
|
94
|
+
}
|
|
95
|
+
return false;
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
render() {
|
|
100
|
+
const [badgeColor, badgeTextColor] = this.getBadgeColors(this.color);
|
|
101
|
+
const { fontSize, padding, minSize } = this.getSizeAttributes(
|
|
102
|
+
this.size,
|
|
103
|
+
);
|
|
104
|
+
const positionStyles = this.getBadgePosition(
|
|
105
|
+
this.position,
|
|
106
|
+
this.alignment,
|
|
107
|
+
);
|
|
108
|
+
const hasTarget = this.hasTargetContent();
|
|
109
|
+
|
|
110
|
+
this.shadowRoot.innerHTML = `
|
|
111
|
+
<style>
|
|
112
|
+
:host {
|
|
113
|
+
position: ${hasTarget ? "relative" : "static"};
|
|
114
|
+
display: inline-flex;
|
|
115
|
+
align-items: center;
|
|
116
|
+
}
|
|
117
|
+
.badge {
|
|
118
|
+
position: ${hasTarget ? "absolute" : "static"};
|
|
119
|
+
${hasTarget ? positionStyles : ""}
|
|
120
|
+
background: ${badgeColor};
|
|
121
|
+
color: ${badgeTextColor};
|
|
122
|
+
font-size: ${fontSize};
|
|
123
|
+
font-weight: bold;
|
|
124
|
+
padding: ${padding};
|
|
125
|
+
border-radius: var(--component-badge-border-radius-circle, 9999px);
|
|
126
|
+
display: flex;
|
|
127
|
+
align-items: center;
|
|
128
|
+
justify-content: center;
|
|
129
|
+
font-family: var(--font-family-body, sans-serif);
|
|
130
|
+
min-width: ${minSize};
|
|
131
|
+
height: ${minSize};
|
|
132
|
+
z-index: 20;
|
|
133
|
+
}
|
|
134
|
+
::slotted(*) {
|
|
135
|
+
position: relative;
|
|
136
|
+
display: inline-block;
|
|
137
|
+
}
|
|
138
|
+
</style>
|
|
139
|
+
${hasTarget ? "<slot></slot>" : ""}
|
|
140
|
+
<div class="badge" part="badge">${this.value}</div>
|
|
141
|
+
`;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (!customElements.get("y-badge")) {
|
|
146
|
+
customElements.define("y-badge", YumeBadge);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export { YumeBadge };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export class YumeButton extends HTMLElement {
|
|
2
|
+
static get observedAttributes(): string[];
|
|
3
|
+
connectedCallback(): void;
|
|
4
|
+
attributeChangedCallback(name: any, oldValue: any, newValue: any): void;
|
|
5
|
+
set value(newVal: any);
|
|
6
|
+
get value(): any;
|
|
7
|
+
selectedValues: any;
|
|
8
|
+
setOptions(options: any): void;
|
|
9
|
+
handleClick(): void;
|
|
10
|
+
init(): void;
|
|
11
|
+
proxyNativeOnClick(): void;
|
|
12
|
+
updateButtonAttributes(): void;
|
|
13
|
+
manageSlotVisibility(slotName: any, selector: any): void;
|
|
14
|
+
render(): void;
|
|
15
|
+
button: HTMLButtonElement;
|
|
16
|
+
applyStyles(): void;
|
|
17
|
+
addEventListeners(): void;
|
|
18
|
+
updateStyles(): void;
|
|
19
|
+
}
|