@suchandan_haldar/web-library 0.0.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.
@@ -0,0 +1,213 @@
1
+ import { LitElement as e, html as t } from "lit";
2
+ import { customElement as n, property as r } from "lit/decorators.js";
3
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorate.js
4
+ function i(e, t, n, r) {
5
+ var i = arguments.length, a = i < 3 ? t : r === null ? r = Object.getOwnPropertyDescriptor(t, n) : r, o;
6
+ if (typeof Reflect == "object" && typeof Reflect.decorate == "function") a = Reflect.decorate(e, t, n, r);
7
+ else for (var s = e.length - 1; s >= 0; s--) (o = e[s]) && (a = (i < 3 ? o(a) : i > 3 ? o(t, n, a) : o(t, n)) || a);
8
+ return i > 3 && a && Object.defineProperty(t, n, a), a;
9
+ }
10
+ //#endregion
11
+ //#region src/components/Button/Button.ts
12
+ var a = class extends e {
13
+ constructor(...e) {
14
+ super(...e), this._originalChildren = [], this.variant = "primary", this.size = "medium";
15
+ }
16
+ createRenderRoot() {
17
+ return this;
18
+ }
19
+ connectedCallback() {
20
+ this._originalChildren.length === 0 && (this._originalChildren = Array.from(this.childNodes)), super.connectedCallback();
21
+ }
22
+ render() {
23
+ return t`
24
+ <button class="btn ${this.variant} ${this.size}" part="button">
25
+ ${this._originalChildren}
26
+ </button>
27
+ `;
28
+ }
29
+ };
30
+ i([r({ type: String })], a.prototype, "variant", void 0), i([r({ type: String })], a.prototype, "size", void 0), a = i([n("wc-button")], a);
31
+ //#endregion
32
+ //#region src/components/Link/Link.ts
33
+ var o = class extends e {
34
+ constructor(...e) {
35
+ super(...e), this._originalChildren = [], this.href = "#";
36
+ }
37
+ createRenderRoot() {
38
+ return this;
39
+ }
40
+ connectedCallback() {
41
+ this._originalChildren.length === 0 && (this._originalChildren = Array.from(this.childNodes)), super.connectedCallback();
42
+ }
43
+ render() {
44
+ return t`
45
+ <a class="link" href="${this.href}" target="${this.target || "_self"}" part="link">
46
+ ${this._originalChildren}
47
+ </a>
48
+ `;
49
+ }
50
+ };
51
+ i([r({ type: String })], o.prototype, "href", void 0), i([r({ type: String })], o.prototype, "target", void 0), o = i([n("wc-link")], o);
52
+ //#endregion
53
+ //#region src/components/Icon/Icon.ts
54
+ var s = class extends e {
55
+ constructor(...e) {
56
+ super(...e), this.name = "", this.size = 24, this.color = "";
57
+ }
58
+ createRenderRoot() {
59
+ return this;
60
+ }
61
+ render() {
62
+ if (!this.name) return t``;
63
+ let e = `
64
+ ${this.size ? `font-size: ${this.size}px;` : ""}
65
+ ${this.color ? `color: ${this.color};` : ""}
66
+ `;
67
+ return t`
68
+ <i
69
+ class="icon ti ti-${this.name}"
70
+ style="${e.trim()}"
71
+ part="icon"
72
+ aria-hidden="true"
73
+ ></i>
74
+ `;
75
+ }
76
+ };
77
+ i([r({ type: String })], s.prototype, "name", void 0), i([r({ type: Number })], s.prototype, "size", void 0), i([r({ type: String })], s.prototype, "color", void 0), s = i([n("wc-icon")], s);
78
+ //#endregion
79
+ //#region src/components/IconButton/IconButton.ts
80
+ var c = class extends e {
81
+ constructor(...e) {
82
+ super(...e), this._originalChildren = [], this.name = "", this.variant = "primary", this.ariaLabel = "";
83
+ }
84
+ createRenderRoot() {
85
+ return this;
86
+ }
87
+ connectedCallback() {
88
+ this._originalChildren.length === 0 && (this._originalChildren = Array.from(this.childNodes)), super.connectedCallback();
89
+ }
90
+ render() {
91
+ return t`
92
+ <button
93
+ class="icon-btn ${this.variant}"
94
+ part="button"
95
+ aria-label="${this.ariaLabel}"
96
+ title="${this.ariaLabel}"
97
+ >
98
+ ${this.name ? t`<wc-icon name="${this.name}"></wc-icon>` : this._originalChildren}
99
+ </button>
100
+ `;
101
+ }
102
+ };
103
+ i([r({ type: String })], c.prototype, "name", void 0), i([r({ type: String })], c.prototype, "variant", void 0), i([r({ type: String })], c.prototype, "ariaLabel", void 0), c = i([n("wc-icon-button")], c);
104
+ //#endregion
105
+ //#region src/components/Tab/Tab.ts
106
+ var l = class extends e {
107
+ constructor(...e) {
108
+ super(...e), this._originalChildren = [], this.active = !1, this.disabled = !1, this.value = "";
109
+ }
110
+ createRenderRoot() {
111
+ return this;
112
+ }
113
+ connectedCallback() {
114
+ this._originalChildren.length === 0 && (this._originalChildren = Array.from(this.childNodes)), super.connectedCallback();
115
+ }
116
+ _getPanelScope() {
117
+ let e = this.closest("[data-wc-tab-group]");
118
+ if (e) return e;
119
+ let t = this.parentElement;
120
+ if (!t) return null;
121
+ if (t.querySelector("wc-tab-panel")) return t;
122
+ let n = t.parentElement;
123
+ return n?.querySelector("wc-tab-panel") ? n : null;
124
+ }
125
+ _syncPanelsForActiveValue() {
126
+ let e = this._getPanelScope();
127
+ if (!e) return;
128
+ let t = Array.from(e.querySelectorAll("wc-tab-panel"));
129
+ for (let e of t) {
130
+ let t = (e.getAttribute("value") || "") === this.value;
131
+ e.toggleAttribute("active", t);
132
+ }
133
+ }
134
+ _activateInParentRow() {
135
+ let e = this.parentElement;
136
+ if (!e) {
137
+ this.active = !0;
138
+ return;
139
+ }
140
+ let t = !1;
141
+ for (let n of Array.from(e.children)) {
142
+ if (n.tagName.toLowerCase() !== "wc-tab") continue;
143
+ t = !0;
144
+ let e = n;
145
+ e.active = e === this;
146
+ }
147
+ t || (this.active = !0);
148
+ }
149
+ _onSelect() {
150
+ this.disabled || (this._activateInParentRow(), this._syncPanelsForActiveValue(), this.dispatchEvent(new CustomEvent("wc-tab-select", {
151
+ detail: { value: this.value },
152
+ bubbles: !0,
153
+ composed: !0
154
+ })));
155
+ }
156
+ render() {
157
+ let e = this.disabled ? -1 : this.active ? 0 : -1;
158
+ return t`
159
+ <button
160
+ type="button"
161
+ class="${`tab ${this.active ? "active" : ""} ${this.disabled ? "disabled" : ""}`.trim()}"
162
+ part="button"
163
+ role="tab"
164
+ aria-selected="${this.active ? "true" : "false"}"
165
+ aria-disabled="${this.disabled ? "true" : "false"}"
166
+ tabindex="${e}"
167
+ ?disabled=${this.disabled}
168
+ @click=${this._onSelect}
169
+ >
170
+ ${this._originalChildren}
171
+ </button>
172
+ `;
173
+ }
174
+ };
175
+ i([r({
176
+ type: Boolean,
177
+ reflect: !0
178
+ })], l.prototype, "active", void 0), i([r({
179
+ type: Boolean,
180
+ reflect: !0
181
+ })], l.prototype, "disabled", void 0), i([r({ type: String })], l.prototype, "value", void 0), l = i([n("wc-tab")], l);
182
+ //#endregion
183
+ //#region src/components/TabPanel/TabPanel.ts
184
+ var u = class extends e {
185
+ constructor(...e) {
186
+ super(...e), this._originalChildren = [], this.active = !1, this.value = "";
187
+ }
188
+ createRenderRoot() {
189
+ return this;
190
+ }
191
+ connectedCallback() {
192
+ this._originalChildren.length === 0 && (this._originalChildren = Array.from(this.childNodes)), super.connectedCallback();
193
+ }
194
+ render() {
195
+ return t`
196
+ <section
197
+ class="tab-panel ${this.active ? "active" : "inactive"}"
198
+ part="panel"
199
+ role="tabpanel"
200
+ aria-hidden="${this.active ? "false" : "true"}"
201
+ ?hidden=${!this.active}
202
+ >
203
+ ${this._originalChildren}
204
+ </section>
205
+ `;
206
+ }
207
+ };
208
+ i([r({
209
+ type: Boolean,
210
+ reflect: !0
211
+ })], u.prototype, "active", void 0), i([r({ type: String })], u.prototype, "value", void 0), u = i([n("wc-tab-panel")], u);
212
+ //#endregion
213
+ export { a as WcButton, s as WcIcon, c as WcIconButton, o as WcLink, l as WcTab, u as WcTabPanel };
@@ -0,0 +1,52 @@
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("lit"),require("lit/decorators.js")):typeof define==`function`&&define.amd?define([`exports`,`lit`,`lit/decorators.js`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.WebLibrary={},e.lit,e.litDecorators))})(this,function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function r(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var i=class extends t.LitElement{constructor(...e){super(...e),this._originalChildren=[],this.variant=`primary`,this.size=`medium`}createRenderRoot(){return this}connectedCallback(){this._originalChildren.length===0&&(this._originalChildren=Array.from(this.childNodes)),super.connectedCallback()}render(){return t.html`
2
+ <button class="btn ${this.variant} ${this.size}" part="button">
3
+ ${this._originalChildren}
4
+ </button>
5
+ `}};r([(0,n.property)({type:String})],i.prototype,`variant`,void 0),r([(0,n.property)({type:String})],i.prototype,`size`,void 0),i=r([(0,n.customElement)(`wc-button`)],i);var a=class extends t.LitElement{constructor(...e){super(...e),this._originalChildren=[],this.href=`#`}createRenderRoot(){return this}connectedCallback(){this._originalChildren.length===0&&(this._originalChildren=Array.from(this.childNodes)),super.connectedCallback()}render(){return t.html`
6
+ <a class="link" href="${this.href}" target="${this.target||`_self`}" part="link">
7
+ ${this._originalChildren}
8
+ </a>
9
+ `}};r([(0,n.property)({type:String})],a.prototype,`href`,void 0),r([(0,n.property)({type:String})],a.prototype,`target`,void 0),a=r([(0,n.customElement)(`wc-link`)],a);var o=class extends t.LitElement{constructor(...e){super(...e),this.name=``,this.size=24,this.color=``}createRenderRoot(){return this}render(){if(!this.name)return t.html``;let e=`
10
+ ${this.size?`font-size: ${this.size}px;`:``}
11
+ ${this.color?`color: ${this.color};`:``}
12
+ `;return t.html`
13
+ <i
14
+ class="icon ti ti-${this.name}"
15
+ style="${e.trim()}"
16
+ part="icon"
17
+ aria-hidden="true"
18
+ ></i>
19
+ `}};r([(0,n.property)({type:String})],o.prototype,`name`,void 0),r([(0,n.property)({type:Number})],o.prototype,`size`,void 0),r([(0,n.property)({type:String})],o.prototype,`color`,void 0),o=r([(0,n.customElement)(`wc-icon`)],o);var s=class extends t.LitElement{constructor(...e){super(...e),this._originalChildren=[],this.name=``,this.variant=`primary`,this.ariaLabel=``}createRenderRoot(){return this}connectedCallback(){this._originalChildren.length===0&&(this._originalChildren=Array.from(this.childNodes)),super.connectedCallback()}render(){return t.html`
20
+ <button
21
+ class="icon-btn ${this.variant}"
22
+ part="button"
23
+ aria-label="${this.ariaLabel}"
24
+ title="${this.ariaLabel}"
25
+ >
26
+ ${this.name?t.html`<wc-icon name="${this.name}"></wc-icon>`:this._originalChildren}
27
+ </button>
28
+ `}};r([(0,n.property)({type:String})],s.prototype,`name`,void 0),r([(0,n.property)({type:String})],s.prototype,`variant`,void 0),r([(0,n.property)({type:String})],s.prototype,`ariaLabel`,void 0),s=r([(0,n.customElement)(`wc-icon-button`)],s);var c=class extends t.LitElement{constructor(...e){super(...e),this._originalChildren=[],this.active=!1,this.disabled=!1,this.value=``}createRenderRoot(){return this}connectedCallback(){this._originalChildren.length===0&&(this._originalChildren=Array.from(this.childNodes)),super.connectedCallback()}_getPanelScope(){let e=this.closest(`[data-wc-tab-group]`);if(e)return e;let t=this.parentElement;if(!t)return null;if(t.querySelector(`wc-tab-panel`))return t;let n=t.parentElement;return n?.querySelector(`wc-tab-panel`)?n:null}_syncPanelsForActiveValue(){let e=this._getPanelScope();if(!e)return;let t=Array.from(e.querySelectorAll(`wc-tab-panel`));for(let e of t){let t=(e.getAttribute(`value`)||``)===this.value;e.toggleAttribute(`active`,t)}}_activateInParentRow(){let e=this.parentElement;if(!e){this.active=!0;return}let t=!1;for(let n of Array.from(e.children)){if(n.tagName.toLowerCase()!==`wc-tab`)continue;t=!0;let e=n;e.active=e===this}t||(this.active=!0)}_onSelect(){this.disabled||(this._activateInParentRow(),this._syncPanelsForActiveValue(),this.dispatchEvent(new CustomEvent(`wc-tab-select`,{detail:{value:this.value},bubbles:!0,composed:!0})))}render(){let e=this.disabled?-1:this.active?0:-1;return t.html`
29
+ <button
30
+ type="button"
31
+ class="${`tab ${this.active?`active`:``} ${this.disabled?`disabled`:``}`.trim()}"
32
+ part="button"
33
+ role="tab"
34
+ aria-selected="${this.active?`true`:`false`}"
35
+ aria-disabled="${this.disabled?`true`:`false`}"
36
+ tabindex="${e}"
37
+ ?disabled=${this.disabled}
38
+ @click=${this._onSelect}
39
+ >
40
+ ${this._originalChildren}
41
+ </button>
42
+ `}};r([(0,n.property)({type:Boolean,reflect:!0})],c.prototype,`active`,void 0),r([(0,n.property)({type:Boolean,reflect:!0})],c.prototype,`disabled`,void 0),r([(0,n.property)({type:String})],c.prototype,`value`,void 0),c=r([(0,n.customElement)(`wc-tab`)],c);var l=class extends t.LitElement{constructor(...e){super(...e),this._originalChildren=[],this.active=!1,this.value=``}createRenderRoot(){return this}connectedCallback(){this._originalChildren.length===0&&(this._originalChildren=Array.from(this.childNodes)),super.connectedCallback()}render(){return t.html`
43
+ <section
44
+ class="tab-panel ${this.active?`active`:`inactive`}"
45
+ part="panel"
46
+ role="tabpanel"
47
+ aria-hidden="${this.active?`false`:`true`}"
48
+ ?hidden=${!this.active}
49
+ >
50
+ ${this._originalChildren}
51
+ </section>
52
+ `}};r([(0,n.property)({type:Boolean,reflect:!0})],l.prototype,`active`,void 0),r([(0,n.property)({type:String})],l.prototype,`value`,void 0),l=r([(0,n.customElement)(`wc-tab-panel`)],l),Object.defineProperty(e,"WcButton",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"WcIcon",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"WcIconButton",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"WcLink",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"WcTab",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"WcTabPanel",{enumerable:!0,get:function(){return l}})});
package/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './dist/index';
package/index.js ADDED
@@ -0,0 +1 @@
1
+ export * from './dist/web-library.es.js';
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "@suchandan_haldar/web-library",
3
+ "version": "0.0.1",
4
+ "type": "module",
5
+ "main": "./dist/web-library.umd.js",
6
+ "module": "./dist/web-library.es.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/web-library.es.js",
12
+ "require": "./dist/web-library.umd.js"
13
+ },
14
+ "./style.css": "./dist/web-library.css"
15
+ },
16
+ "publishConfig": {
17
+ "access": "public"
18
+ },
19
+ "files": [
20
+ "dist",
21
+ "index.js",
22
+ "index.d.ts"
23
+ ],
24
+ "scripts": {
25
+ "dev": "vite",
26
+ "build": "tsc && vite build",
27
+ "preview": "vite preview",
28
+ "test": "vitest run",
29
+ "storybook": "storybook dev -p 6006",
30
+ "build-storybook": "storybook build"
31
+ },
32
+ "dependencies": {
33
+ "@tabler/icons-webfont": "^3.40.0",
34
+ "lit": "^3.3.2"
35
+ },
36
+ "devDependencies": {
37
+ "@chromatic-com/storybook": "^5.0.1",
38
+ "@storybook/addon-a11y": "^10.2.19",
39
+ "@storybook/addon-docs": "^10.2.19",
40
+ "@storybook/addon-vitest": "^10.2.19",
41
+ "@storybook/web-components-vite": "^10.2.19",
42
+ "@vitest/browser-playwright": "^4.1.9",
43
+ "@vitest/coverage-v8": "^4.1.9",
44
+ "playwright": "^1.58.2",
45
+ "sass": "^1.98.0",
46
+ "storybook": "^10.2.19",
47
+ "typescript": "~5.9.3",
48
+ "vite": "^8.0.0",
49
+ "vite-plugin-dts": "^5.0.2",
50
+ "vitest": "^4.1.9"
51
+ },
52
+ "overrides": {
53
+ "esbuild": "^0.28.1"
54
+ }
55
+ }