@diniz/webcomponents 1.1.7 → 1.1.8
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/README.md +65 -0
- package/dist/README.md +65 -0
- package/dist/{button-demo-BcfxxPSq.js → button-demo-QJVH1hrf.js} +1 -1
- package/dist/{card-demo-Cxp-wRGW.js → card-demo-Czal_vad.js} +1 -1
- package/dist/{date-picker-demo-B8y3zapN.js → date-picker-demo-Nh8Y6BQM.js} +1 -1
- package/dist/{form-demo-page-F1iLCgfh.js → form-demo-page-g2zcnZrj.js} +1 -1
- package/dist/{home-page-XUM8cHP7.js → home-page-CY0gTS-z.js} +1 -1
- package/dist/{index-DiYekJaQ.js → index-DY67xf57.js} +14 -14
- package/dist/index.d.ts +1 -0
- package/dist/{layout-demo-CJsZ6DI5.js → layout-demo-DmPHnT5L.js} +1 -1
- package/dist/{modal-demo-page-YN2KgJ31.js → modal-demo-page-B0VPM0tc.js} +1 -1
- package/dist/{stepper-demo-page-BkcpKk_F.js → stepper-demo-page-BBKHJEUF.js} +1 -1
- package/dist/{table-demo-x2ZD8cFh.js → table-demo-BZcyUIS5.js} +1 -1
- package/dist/{tabs-demo-BQBtZzw9.js → tabs-demo-B4k7z8lN.js} +1 -1
- package/dist/{toast-demo-page-DLVacHXA.js → toast-demo-page-CIjro0OH.js} +1 -1
- package/dist/webcomponents.es.js +1 -1
- package/dist/webcomponents.umd.js +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -412,6 +412,71 @@ That's it! Your app now has client-side routing with:
|
|
|
412
412
|
|
|
413
413
|
For detailed documentation on each component, see the demo implementations in `src/features/`.
|
|
414
414
|
|
|
415
|
+
## TypeScript Types
|
|
416
|
+
|
|
417
|
+
The library ships first-class TypeScript types. Import them with `type` to keep builds tree-shakeable:
|
|
418
|
+
|
|
419
|
+
```typescript
|
|
420
|
+
import type {
|
|
421
|
+
ButtonVariant,
|
|
422
|
+
ButtonSize,
|
|
423
|
+
InputType,
|
|
424
|
+
ValidationResult,
|
|
425
|
+
TableColumn,
|
|
426
|
+
SelectOption,
|
|
427
|
+
ToastConfig,
|
|
428
|
+
StepperStep,
|
|
429
|
+
Route,
|
|
430
|
+
Signal
|
|
431
|
+
} from '@diniz/webcomponents';
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
### Example: Table column typing
|
|
435
|
+
|
|
436
|
+
```typescript
|
|
437
|
+
import type { TableColumn } from '@diniz/webcomponents';
|
|
438
|
+
|
|
439
|
+
type User = { id: number; name: string; email: string };
|
|
440
|
+
|
|
441
|
+
const columns: TableColumn<User>[] = [
|
|
442
|
+
{ key: 'id', label: 'ID' },
|
|
443
|
+
{ key: 'name', label: 'Name' },
|
|
444
|
+
{ key: 'email', label: 'Email' }
|
|
445
|
+
];
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
### Example: Button variants and sizes
|
|
449
|
+
|
|
450
|
+
```typescript
|
|
451
|
+
import type { ButtonVariant, ButtonSize } from '@diniz/webcomponents';
|
|
452
|
+
|
|
453
|
+
const variant: ButtonVariant = 'primary';
|
|
454
|
+
const size: ButtonSize = 'md';
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
### Example: Form validation results
|
|
458
|
+
|
|
459
|
+
```typescript
|
|
460
|
+
import type { ValidationResult } from '@diniz/webcomponents';
|
|
461
|
+
|
|
462
|
+
const result: ValidationResult = {
|
|
463
|
+
valid: false,
|
|
464
|
+
message: 'Email is required'
|
|
465
|
+
};
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
### Example: Router types
|
|
469
|
+
|
|
470
|
+
```typescript
|
|
471
|
+
import { createRouter, type Route } from '@diniz/webcomponents';
|
|
472
|
+
|
|
473
|
+
const routes: Route[] = [
|
|
474
|
+
{ path: '/', load: () => import('./pages/home'), component: 'home-page' }
|
|
475
|
+
];
|
|
476
|
+
|
|
477
|
+
createRouter(routes);
|
|
478
|
+
```
|
|
479
|
+
|
|
415
480
|
## Core Features
|
|
416
481
|
|
|
417
482
|
### Signals & Reactivity
|
package/dist/README.md
CHANGED
|
@@ -412,6 +412,71 @@ That's it! Your app now has client-side routing with:
|
|
|
412
412
|
|
|
413
413
|
For detailed documentation on each component, see the demo implementations in `src/features/`.
|
|
414
414
|
|
|
415
|
+
## TypeScript Types
|
|
416
|
+
|
|
417
|
+
The library ships first-class TypeScript types. Import them with `type` to keep builds tree-shakeable:
|
|
418
|
+
|
|
419
|
+
```typescript
|
|
420
|
+
import type {
|
|
421
|
+
ButtonVariant,
|
|
422
|
+
ButtonSize,
|
|
423
|
+
InputType,
|
|
424
|
+
ValidationResult,
|
|
425
|
+
TableColumn,
|
|
426
|
+
SelectOption,
|
|
427
|
+
ToastConfig,
|
|
428
|
+
StepperStep,
|
|
429
|
+
Route,
|
|
430
|
+
Signal
|
|
431
|
+
} from '@diniz/webcomponents';
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
### Example: Table column typing
|
|
435
|
+
|
|
436
|
+
```typescript
|
|
437
|
+
import type { TableColumn } from '@diniz/webcomponents';
|
|
438
|
+
|
|
439
|
+
type User = { id: number; name: string; email: string };
|
|
440
|
+
|
|
441
|
+
const columns: TableColumn<User>[] = [
|
|
442
|
+
{ key: 'id', label: 'ID' },
|
|
443
|
+
{ key: 'name', label: 'Name' },
|
|
444
|
+
{ key: 'email', label: 'Email' }
|
|
445
|
+
];
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
### Example: Button variants and sizes
|
|
449
|
+
|
|
450
|
+
```typescript
|
|
451
|
+
import type { ButtonVariant, ButtonSize } from '@diniz/webcomponents';
|
|
452
|
+
|
|
453
|
+
const variant: ButtonVariant = 'primary';
|
|
454
|
+
const size: ButtonSize = 'md';
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
### Example: Form validation results
|
|
458
|
+
|
|
459
|
+
```typescript
|
|
460
|
+
import type { ValidationResult } from '@diniz/webcomponents';
|
|
461
|
+
|
|
462
|
+
const result: ValidationResult = {
|
|
463
|
+
valid: false,
|
|
464
|
+
message: 'Email is required'
|
|
465
|
+
};
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
### Example: Router types
|
|
469
|
+
|
|
470
|
+
```typescript
|
|
471
|
+
import { createRouter, type Route } from '@diniz/webcomponents';
|
|
472
|
+
|
|
473
|
+
const routes: Route[] = [
|
|
474
|
+
{ path: '/', load: () => import('./pages/home'), component: 'home-page' }
|
|
475
|
+
];
|
|
476
|
+
|
|
477
|
+
createRouter(routes);
|
|
478
|
+
```
|
|
479
|
+
|
|
415
480
|
## Core Features
|
|
416
481
|
|
|
417
482
|
### Signals & Reactivity
|
|
@@ -358,18 +358,18 @@ class I extends g {
|
|
|
358
358
|
constructor() {
|
|
359
359
|
super(...arguments);
|
|
360
360
|
p(this, "inputElement", null);
|
|
361
|
-
p(this, "
|
|
361
|
+
p(this, "isComponentConnected", !1);
|
|
362
362
|
p(this, "isInternalUpdate", !1);
|
|
363
363
|
p(this, "hasRendered", !1);
|
|
364
364
|
}
|
|
365
365
|
connectedCallback() {
|
|
366
|
-
this.setAttribute("data-ui", "date-picker"), super.connectedCallback(), this.
|
|
366
|
+
this.setAttribute("data-ui", "date-picker"), super.connectedCallback(), this.isComponentConnected = !0;
|
|
367
367
|
}
|
|
368
368
|
static get observedAttributes() {
|
|
369
369
|
return ["value", "format", "min", "max", "disabled", "placeholder", "label"];
|
|
370
370
|
}
|
|
371
371
|
attributeChangedCallback(t, e, a) {
|
|
372
|
-
if (!(!this.
|
|
372
|
+
if (!(!this.isComponentConnected || e === a)) {
|
|
373
373
|
if (this.isInternalUpdate && t === "value") {
|
|
374
374
|
this.isInternalUpdate = !1;
|
|
375
375
|
return;
|
|
@@ -2206,67 +2206,67 @@ const at = [
|
|
|
2206
2206
|
{
|
|
2207
2207
|
path: "/",
|
|
2208
2208
|
layout: "app-layout",
|
|
2209
|
-
load: () => import("./home-page-
|
|
2209
|
+
load: () => import("./home-page-CY0gTS-z.js"),
|
|
2210
2210
|
component: "home-page"
|
|
2211
2211
|
},
|
|
2212
2212
|
{
|
|
2213
2213
|
path: "/button",
|
|
2214
2214
|
layout: "app-layout",
|
|
2215
|
-
load: () => import("./button-demo-
|
|
2215
|
+
load: () => import("./button-demo-QJVH1hrf.js"),
|
|
2216
2216
|
component: "button-demo"
|
|
2217
2217
|
},
|
|
2218
2218
|
{
|
|
2219
2219
|
path: "/layout",
|
|
2220
2220
|
layout: "app-layout",
|
|
2221
|
-
load: () => import("./layout-demo-
|
|
2221
|
+
load: () => import("./layout-demo-DmPHnT5L.js"),
|
|
2222
2222
|
component: "layout-demo"
|
|
2223
2223
|
},
|
|
2224
2224
|
{
|
|
2225
2225
|
path: "/date-picker",
|
|
2226
2226
|
layout: "app-layout",
|
|
2227
|
-
load: () => import("./date-picker-demo-
|
|
2227
|
+
load: () => import("./date-picker-demo-Nh8Y6BQM.js"),
|
|
2228
2228
|
component: "date-picker-demo"
|
|
2229
2229
|
},
|
|
2230
2230
|
{
|
|
2231
2231
|
path: "/table-demo",
|
|
2232
2232
|
layout: "app-layout",
|
|
2233
|
-
load: () => import("./table-demo-
|
|
2233
|
+
load: () => import("./table-demo-BZcyUIS5.js"),
|
|
2234
2234
|
component: "table-demo"
|
|
2235
2235
|
},
|
|
2236
2236
|
{
|
|
2237
2237
|
path: "/forms",
|
|
2238
2238
|
layout: "app-layout",
|
|
2239
|
-
load: () => import("./form-demo-page-
|
|
2239
|
+
load: () => import("./form-demo-page-g2zcnZrj.js"),
|
|
2240
2240
|
component: "form-demo-page"
|
|
2241
2241
|
},
|
|
2242
2242
|
{
|
|
2243
2243
|
path: "/modal",
|
|
2244
2244
|
layout: "app-layout",
|
|
2245
|
-
load: () => import("./modal-demo-page-
|
|
2245
|
+
load: () => import("./modal-demo-page-B0VPM0tc.js"),
|
|
2246
2246
|
component: "modal-demo-page"
|
|
2247
2247
|
},
|
|
2248
2248
|
{
|
|
2249
2249
|
path: "/tabs",
|
|
2250
2250
|
layout: "app-layout",
|
|
2251
|
-
load: () => import("./tabs-demo-
|
|
2251
|
+
load: () => import("./tabs-demo-B4k7z8lN.js"),
|
|
2252
2252
|
component: "tabs-demo"
|
|
2253
2253
|
},
|
|
2254
2254
|
{
|
|
2255
2255
|
path: "/card",
|
|
2256
2256
|
layout: "app-layout",
|
|
2257
|
-
load: () => import("./card-demo-
|
|
2257
|
+
load: () => import("./card-demo-Czal_vad.js"),
|
|
2258
2258
|
component: "card-demo-page"
|
|
2259
2259
|
},
|
|
2260
2260
|
{
|
|
2261
2261
|
path: "/toast",
|
|
2262
2262
|
layout: "app-layout",
|
|
2263
|
-
load: () => import("./toast-demo-page-
|
|
2263
|
+
load: () => import("./toast-demo-page-CIjro0OH.js"),
|
|
2264
2264
|
component: "toast-demo-page"
|
|
2265
2265
|
},
|
|
2266
2266
|
{
|
|
2267
2267
|
path: "/stepper",
|
|
2268
2268
|
layout: "app-layout",
|
|
2269
|
-
load: () => import("./stepper-demo-page-
|
|
2269
|
+
load: () => import("./stepper-demo-page-BBKHJEUF.js"),
|
|
2270
2270
|
component: "stepper-demo-page"
|
|
2271
2271
|
}
|
|
2272
2272
|
];
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './lib/index';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var m = Object.defineProperty;
|
|
2
2
|
var g = (n, r, e) => r in n ? m(n, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[r] = e;
|
|
3
3
|
var c = (n, r, e) => g(n, typeof r != "symbol" ? r + "" : r, e);
|
|
4
|
-
import { B as h } from "./index-
|
|
4
|
+
import { B as h } from "./index-DY67xf57.js";
|
|
5
5
|
const u = `
|
|
6
6
|
<section class="stepper-hero">
|
|
7
7
|
<div>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var u = Object.defineProperty;
|
|
2
2
|
var p = (d, i, e) => i in d ? u(d, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : d[i] = e;
|
|
3
3
|
var r = (d, i, e) => p(d, typeof i != "symbol" ? i + "" : i, e);
|
|
4
|
-
import { B as b, h as f, q as y, a as k, b as w } from "./index-
|
|
4
|
+
import { B as b, h as f, q as y, a as k, b as w } from "./index-DY67xf57.js";
|
|
5
5
|
const v = `<h1>Table Demo</h1>
|
|
6
6
|
<p class="intro">Example of loading JSON data and rendering a table.</p>
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var r = Object.defineProperty;
|
|
2
2
|
var h = (i, o, n) => o in i ? r(i, o, { enumerable: !0, configurable: !0, writable: !0, value: n }) : i[o] = n;
|
|
3
3
|
var s = (i, o, n) => h(i, typeof o != "symbol" ? o + "" : o, n);
|
|
4
|
-
import { B as c, d as t, e as a } from "./index-
|
|
4
|
+
import { B as c, d as t, e as a } from "./index-DY67xf57.js";
|
|
5
5
|
const d = `<div class="demo-container">
|
|
6
6
|
<h1>Toast Component Demo</h1>
|
|
7
7
|
<p>Elegant notification system with smooth animations and glassmorphic design.</p>
|
package/dist/webcomponents.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as s, H as t, U as o, f as I, i as U, j as r, k as n, l as u, m as y, n as l, o as d, p as i, r as p, s as m, t as b, u as q, w as C, x as L, y as T, z as c, d as g, A as B, e as E, g as P, h, c as k, C as x, q as H, b as S, a as f } from "./index-
|
|
1
|
+
import { B as s, H as t, U as o, f as I, i as U, j as r, k as n, l as u, m as y, n as l, o as d, p as i, r as p, s as m, t as b, u as q, w as C, x as L, y as T, z as c, d as g, A as B, e as E, g as P, h, c as k, C as x, q as H, b as S, a as f } from "./index-DY67xf57.js";
|
|
2
2
|
export {
|
|
3
3
|
s as BaseComponent,
|
|
4
4
|
t as HTTPClient,
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
<tbody>${o}</tbody>
|
|
43
43
|
</table>
|
|
44
44
|
</div>
|
|
45
|
-
`,this.shadowRoot.querySelectorAll(".action-btn").forEach(i=>{i.addEventListener("click",s=>{const n=s.currentTarget,r=n.dataset.action,l=parseInt(n.dataset.rowIndex||"0",10),c=r==="edit"?"edit-action":"delete-action";this.dispatchEvent(new CustomEvent(c,{bubbles:!0,composed:!0,detail:{row:this.rows[l],rowIndex:l}}))})})}}customElements.define("ui-table",q);class B extends b{constructor(){super(...arguments);p(this,"inputElement",null);p(this,"
|
|
45
|
+
`,this.shadowRoot.querySelectorAll(".action-btn").forEach(i=>{i.addEventListener("click",s=>{const n=s.currentTarget,r=n.dataset.action,l=parseInt(n.dataset.rowIndex||"0",10),c=r==="edit"?"edit-action":"delete-action";this.dispatchEvent(new CustomEvent(c,{bubbles:!0,composed:!0,detail:{row:this.rows[l],rowIndex:l}}))})})}}customElements.define("ui-table",q);class B extends b{constructor(){super(...arguments);p(this,"inputElement",null);p(this,"isComponentConnected",!1);p(this,"isInternalUpdate",!1);p(this,"hasRendered",!1)}connectedCallback(){this.setAttribute("data-ui","date-picker"),super.connectedCallback(),this.isComponentConnected=!0}static get observedAttributes(){return["value","format","min","max","disabled","placeholder","label"]}attributeChangedCallback(t,e,o){if(!(!this.isComponentConnected||e===o)){if(this.isInternalUpdate&&t==="value"){this.isInternalUpdate=!1;return}t==="value"?this.updateInputValues():this.render()}}updateInputValues(){if(!this.shadowRoot)return;const t=this.shadowRoot.querySelector(".formatted-input"),e=this.shadowRoot.querySelector('input[type="date"]');if(t&&e){const o=this.getValue(),i=this.getFormat(),s=this.formatDate(o,i);t.value=s,e.value=o}}getFormat(){const t=this.getAttribute("format");return t==="DD/MM/YYYY"||t==="MM/DD/YYYY"||t==="DD-MM-YYYY"||t==="MM-DD-YYYY"?t:"YYYY-MM-DD"}getValue(){return this.getAttribute("value")||""}getMin(){return this.getAttribute("min")||""}getMax(){return this.getAttribute("max")||""}getPlaceholder(){return this.getAttribute("placeholder")||this.getFormat()}getLabel(){return this.getAttribute("label")||""}isDisabled(){return this.hasAttribute("disabled")}formatDate(t,e){if(!t)return"";const o=t.split("-");if(o.length!==3)return t;const[i,s,n]=o;switch(e){case"DD/MM/YYYY":return`${n}/${s}/${i}`;case"MM/DD/YYYY":return`${s}/${n}/${i}`;case"DD-MM-YYYY":return`${n}-${s}-${i}`;case"MM-DD-YYYY":return`${s}-${n}-${i}`;case"YYYY-MM-DD":default:return t}}parseDate(t,e){if(!t)return"";let o,i,s,n;switch(e){case"DD/MM/YYYY":if(o=t.split("/"),o.length!==3)return"";[n,s,i]=o;break;case"MM/DD/YYYY":if(o=t.split("/"),o.length!==3)return"";[s,n,i]=o;break;case"DD-MM-YYYY":if(o=t.split("-"),o.length!==3)return"";[n,s,i]=o;break;case"MM-DD-YYYY":if(o=t.split("-"),o.length!==3)return"";[s,n,i]=o;break;case"YYYY-MM-DD":default:return t}return s=s.padStart(2,"0"),n=n.padStart(2,"0"),`${i}-${s}-${n}`}attachEventListeners(){if(!this.shadowRoot)return;const t=this.shadowRoot.querySelector(".formatted-input"),e=this.shadowRoot.querySelector('input[type="date"]'),o=this.shadowRoot.querySelector(".calendar-btn");if(!t||!e)return;const i=()=>{const s=t.value,n=this.getFormat(),r=this.parseDate(s,n);this.isValidDate(r)?(e.value=r,t.classList.remove("invalid"),this.dispatchDateChange(r)):s===""?(e.value="",t.classList.remove("invalid"),this.dispatchDateChange("")):t.classList.add("invalid")};t.addEventListener("blur",i),t.addEventListener("keydown",s=>{s.key==="Enter"&&(i(),t.blur())}),e.addEventListener("change",s=>{const r=s.target.value,l=this.getFormat(),c=this.formatDate(r,l);t.value=c,t.classList.remove("invalid"),this.dispatchDateChange(r)}),o&&o.addEventListener("click",async s=>{s.preventDefault(),s.stopPropagation(),e.style.pointerEvents="auto";try{typeof e.showPicker=="function"?e.showPicker():(e.focus(),e.click())}catch(n){console.log("Date picker error:",n),e.focus(),e.click()}finally{setTimeout(()=>{e.style.pointerEvents="none"},100)}})}isValidDate(t){if(!t)return!1;const e=new Date(t);return e instanceof Date&&!isNaN(e.getTime())}dispatchDateChange(t){const e=this.getFormat(),o=this.formatDate(t,e);this.dispatchEvent(new CustomEvent("date-change",{detail:{value:t,formattedValue:o,format:e},bubbles:!0,composed:!0})),this.isInternalUpdate=!0,this.setAttribute("value",t)}getISOValue(){return this.getValue()}getFormattedValue(){const t=this.getValue(),e=this.getFormat();return this.formatDate(t,e)}setValue(t){this.setAttribute("value",t)}clear(){this.setAttribute("value","")}render(){const t=this.getValue(),e=this.getFormat(),o=this.getMin(),i=this.getMax(),s=this.isDisabled(),n=this.getPlaceholder(),r=this.getLabel(),l=this.formatDate(t,e),c=r!=="";this.shadowRoot.innerHTML=`
|
|
46
46
|
<style>${f}</style>
|
|
47
47
|
<div class="date-picker-container">
|
|
48
48
|
${c?`<label class="date-picker-label">${r}</label>`:""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@diniz/webcomponents",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.8",
|
|
4
4
|
"description": "Lightweight web components library",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/webcomponents.umd.js",
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
11
12
|
"import": "./dist/webcomponents.es.js",
|
|
12
13
|
"require": "./dist/webcomponents.umd.js"
|
|
13
14
|
},
|
|
@@ -20,7 +21,7 @@
|
|
|
20
21
|
"dev": "vite",
|
|
21
22
|
"build": "vite build",
|
|
22
23
|
"build:prod": "vite build --mode production",
|
|
23
|
-
"build:lib": "vite build --config vite.lib.config.ts && node scripts/copy-lib-assets.mjs",
|
|
24
|
+
"build:lib": "tsc -p tsconfig.build.json && vite build --config vite.lib.config.ts && node scripts/copy-lib-assets.mjs",
|
|
24
25
|
"preview": "vite preview",
|
|
25
26
|
"preview:prod": "vite preview --port 4173"
|
|
26
27
|
},
|