@kashi-ui/elements 2.24.0 → 2.25.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/README.md +3 -3
- package/dist/base.d.ts +110 -0
- package/dist/capture.d.ts +75 -0
- package/dist/capture.js +456 -0
- package/dist/cdn/{appointment-DOXBUwIU.js → appointment-BaEWfjSX.js} +1 -1
- package/dist/cdn/base-BqFAMlwG.js +1 -0
- package/dist/cdn/{basic-DuY4RslZ.js → basic-BBvsRt91.js} +1 -1
- package/dist/cdn/{buttons-BaK6bx3w.js → buttons-BmP5wikN.js} +1 -1
- package/dist/cdn/{calendar-BulPeVAJ.js → calendar-CwKogl-G.js} +1 -1
- package/dist/cdn/capture-B48H5hmR.js +24 -0
- package/dist/cdn/{card-BKiwJF34.js → card-C0nariT-.js} +1 -1
- package/dist/cdn/{cards-DKarXHsC.js → cards-D9-wNDK8.js} +1 -1
- package/dist/cdn/{charts-ETYOAJyB.js → charts-Cct32znI.js} +1 -1
- package/dist/cdn/{chat-D5ZIMnNp.js → chat-Dg5CEN6Y.js} +1 -1
- package/dist/cdn/{choice-DBvC2Puo.js → choice-cDqbHUTC.js} +1 -1
- package/dist/cdn/combobox-Drm8K9Zk.js +1 -0
- package/dist/cdn/commerce-JkDctt2h.js +1 -0
- package/dist/cdn/{content-BgfBfy8j.js → content-CqUXcDCi.js} +1 -1
- package/dist/cdn/{controls--OMZkJYe.js → controls-CquzGwtr.js} +1 -1
- package/dist/cdn/{display-BfYWAjNu.js → display-DW5JEQXT.js} +1 -1
- package/dist/cdn/{fields-B-jTUQiI.js → fields-C-ytjZil.js} +1 -1
- package/dist/cdn/forms-CurTYl2V.js +1 -0
- package/dist/cdn/gantt-QfHFG7O8.js +14 -0
- package/dist/cdn/{holidays-Cu6IfbTL.js → holidays-DgmHlqJX.js} +1 -1
- package/dist/cdn/{hours-CeiVqPKD.js → hours-CmICISQO.js} +1 -1
- package/dist/cdn/inputs-DWLKbi57.js +1 -0
- package/dist/cdn/invoice-BUMyjBVi.js +10 -0
- package/dist/cdn/kashi-elements.js +1 -1
- package/dist/cdn/{legal-id-Mt8FX0fV.js → legal-id-B_0kbcQT.js} +1 -1
- package/dist/cdn/lists-D0dao20N.js +1 -0
- package/dist/cdn/{map-TfSt3CjL.js → map-BxlzfCbM.js} +1 -1
- package/dist/cdn/{media-BRBINvzU.js → media-QVgCYQSu.js} +1 -1
- package/dist/cdn/{menu-DTNVFXrb.js → menu-DcFyTTHv.js} +1 -1
- package/dist/cdn/{money-CjGI2VIQ.js → money-BFEbgLJn.js} +1 -1
- package/dist/cdn/{nav-CT5RVOzy.js → nav-Cm8mAT09.js} +1 -1
- package/dist/cdn/{overlay-CS8piW6X.js → overlay-C1nbLv6h.js} +1 -1
- package/dist/cdn/pickers-DQgK1WAX.js +1 -0
- package/dist/cdn/{relative-OC1fV3Xh.js → relative-BoBZPiB7.js} +1 -1
- package/dist/cdn/{rich-text-CS6xEim6.js → rich-text-9IAZ_T8A.js} +1 -1
- package/dist/cdn/search-BvShDz2X.js +1 -0
- package/dist/cdn/{sheets-eVMx4d-5.js → sheets-CNF5lSVn.js} +1 -1
- package/dist/cdn/table-D1xiHZCM.js +2 -0
- package/dist/cdn/{text-C6fzEBBh.js → text-DFyW6cuq.js} +1 -1
- package/dist/cdn/{time-CkqqUKJv.js → time-CYZzyy_3.js} +1 -1
- package/dist/cdn/{time-CwOYrtK-.js → time-oyKIQ2bk.js} +1 -1
- package/dist/cdn/{validate-Dr2f6i6s.js → validate-CRU7rfNs.js} +1 -1
- package/dist/cdn/{work-DoNAKgVU.js → work-DS2MbtGM.js} +1 -1
- package/dist/cdn.js +5 -1
- package/dist/combobox.js +4 -4
- package/dist/commerce.js +2 -2
- package/dist/content.js +2 -1
- package/dist/gantt.d.ts +41 -0
- package/dist/gantt.js +179 -0
- package/dist/index.d.ts +18 -3
- package/dist/index.js +8 -3
- package/dist/inputs.d.ts +16 -0
- package/dist/inputs.js +62 -2
- package/dist/invoice.d.ts +52 -0
- package/dist/invoice.js +75 -0
- package/dist/lists.d.ts +57 -0
- package/dist/lists.js +306 -0
- package/dist/manifest.json +168 -3
- package/dist/pickers.d.ts +4 -0
- package/dist/pickers.js +34 -6
- package/dist/sheets.js +1 -1
- package/dist/table.d.ts +15 -1
- package/dist/table.js +184 -5
- package/package.json +4 -4
- package/dist/cdn/base-D4tCOysh.js +0 -1
- package/dist/cdn/combobox-BGuPAAt3.js +0 -1
- package/dist/cdn/commerce-SzWdpWJG.js +0 -1
- package/dist/cdn/forms-DgRiYmdV.js +0 -1
- package/dist/cdn/inputs-BkJ70Xkc.js +0 -1
- package/dist/cdn/pickers-BwDRsDRo.js +0 -1
- package/dist/cdn/table-tgB4iwcM.js +0 -1
package/dist/commerce.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// نسخهٔ ۲: کامپوننتهای فروشگاهی — جستجو با پیشنهاد، بازهٔ قیمت و نمونهٔ رنگ؛ همان کلاسها و رفتار نسخهٔ React
|
|
2
|
-
import { formatNumber, toEnDigits } from "@kashi-ui/persian";
|
|
2
|
+
import { formatNumber, persianFilter, toEnDigits } from "@kashi-ui/persian";
|
|
3
3
|
import { define, digitsOf, emit, esc, HTMLBase, lang, msg, uid } from "./base.js";
|
|
4
4
|
const norm = (s) => s.replace(/[يى]/g, "ی").replace(/ك/g, "ک").replace(/[\s]+/g, " ").trim().toLowerCase();
|
|
5
5
|
const list = (v) => (v ?? "").split(/[,،]/).map((s) => s.trim()).filter(Boolean);
|
|
@@ -209,7 +209,7 @@ export class KashiSearchSuggest extends HTMLBase {
|
|
|
209
209
|
}
|
|
210
210
|
get hits() {
|
|
211
211
|
const n = norm(this.q);
|
|
212
|
-
return n ? list(this.getAttribute("suggestions"))
|
|
212
|
+
return n ? persianFilter(list(this.getAttribute("suggestions")), this.q).slice(0, 8) : [];
|
|
213
213
|
}
|
|
214
214
|
render() {
|
|
215
215
|
const M = msg().searchSuggest;
|
package/dist/content.js
CHANGED
|
@@ -478,7 +478,8 @@ export class KashiMeter extends HTMLBase {
|
|
|
478
478
|
const box = this.box;
|
|
479
479
|
box.dataset.status = status;
|
|
480
480
|
box.querySelector(".k-meter__label").textContent = label;
|
|
481
|
-
|
|
481
|
+
// «۷۰ از ۱۰۰» مثل نسخهٔ React؛ بدون ویژگی of، «از» از پیامهای محلی
|
|
482
|
+
box.querySelector(".k-meter__value").innerHTML = `${esc(fmt(v))} <span>${esc(of != null ? `${of} ${fmt(max)}` : msg().common.of("", fmt(max)).trim())}</span>`;
|
|
482
483
|
const track = box.querySelector(".k-meter__track");
|
|
483
484
|
track.setAttribute("aria-valuenow", String(v));
|
|
484
485
|
track.setAttribute("aria-valuemax", String(max));
|
package/dist/gantt.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { HTMLBase } from "./base.js";
|
|
2
|
+
export interface GanttTaskInput {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
/** Date یا رشتهٔ YYYY-MM-DD */
|
|
6
|
+
start: Date | string;
|
|
7
|
+
end: Date | string;
|
|
8
|
+
progress?: number;
|
|
9
|
+
color?: string;
|
|
10
|
+
dependsOn?: string[];
|
|
11
|
+
milestone?: boolean;
|
|
12
|
+
}
|
|
13
|
+
interface Task {
|
|
14
|
+
id: string;
|
|
15
|
+
name: string;
|
|
16
|
+
start: Date;
|
|
17
|
+
end: Date;
|
|
18
|
+
progress: number;
|
|
19
|
+
color?: string;
|
|
20
|
+
dependsOn: string[];
|
|
21
|
+
milestone: boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* نمودار گانت شمسی: کارها از ویژگی tasks (JSON) یا element.tasks، با from و to و today اختیاری.
|
|
25
|
+
* با editable نوارها با ماوس و کیبورد جابهجا و کشیده میشوند و رویداد kashi-change با { id, start, end } میآید
|
|
26
|
+
* (تاریخ کار در خود عنصر هم بهروز میشود). holidays="false" تعطیلات رسمی را رنگ نمیزند.
|
|
27
|
+
*/
|
|
28
|
+
export declare class KashiGantt extends HTMLBase {
|
|
29
|
+
static observedAttributes: string[];
|
|
30
|
+
private data;
|
|
31
|
+
private drag;
|
|
32
|
+
connectedCallback(): void;
|
|
33
|
+
attributeChangedCallback(n: string, old: string | null, next: string | null): void;
|
|
34
|
+
get tasks(): Task[];
|
|
35
|
+
set tasks(v: GanttTaskInput[]);
|
|
36
|
+
private norm;
|
|
37
|
+
private render;
|
|
38
|
+
private change;
|
|
39
|
+
private wire;
|
|
40
|
+
}
|
|
41
|
+
export {};
|
package/dist/gantt.js
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
// نمودار گانت با تقویم شمسی: همان نشانهگذاری k-gantt نسخهٔ React.
|
|
2
|
+
import { formatJalali, getIranHoliday, toJalali } from "@kashi-ui/persian";
|
|
3
|
+
import { bool, calendarNames, define, digitsOf, emit, esc, HTMLBase, lang, msg, num } from "./base.js";
|
|
4
|
+
import { isRtl, jsonAttr, toDate } from "./parts.js";
|
|
5
|
+
const DAY = 86400000;
|
|
6
|
+
/** YYYY-MM-DD به وقت محلی (نه UTC)، تا روز در هیچ منطقهٔ زمانی جابهجا نشود */
|
|
7
|
+
const dt = (v) => (typeof v === "string" && /^\d{4}-\d{2}-\d{2}$/.test(v) ? new Date(+v.slice(0, 4), +v.slice(5, 7) - 1, +v.slice(8, 10)) : toDate(v));
|
|
8
|
+
const mid = (d) => new Date(d.getFullYear(), d.getMonth(), d.getDate());
|
|
9
|
+
const add = (d, n) => new Date(d.getFullYear(), d.getMonth(), d.getDate() + n);
|
|
10
|
+
const diff = (a, b) => Math.round((mid(b).getTime() - mid(a).getTime()) / DAY);
|
|
11
|
+
/**
|
|
12
|
+
* نمودار گانت شمسی: کارها از ویژگی tasks (JSON) یا element.tasks، با from و to و today اختیاری.
|
|
13
|
+
* با editable نوارها با ماوس و کیبورد جابهجا و کشیده میشوند و رویداد kashi-change با { id, start, end } میآید
|
|
14
|
+
* (تاریخ کار در خود عنصر هم بهروز میشود). holidays="false" تعطیلات رسمی را رنگ نمیزند.
|
|
15
|
+
*/
|
|
16
|
+
export class KashiGantt extends HTMLBase {
|
|
17
|
+
constructor() {
|
|
18
|
+
super(...arguments);
|
|
19
|
+
this.data = null;
|
|
20
|
+
this.drag = null;
|
|
21
|
+
}
|
|
22
|
+
connectedCallback() {
|
|
23
|
+
this.render();
|
|
24
|
+
}
|
|
25
|
+
attributeChangedCallback(n, old, next) {
|
|
26
|
+
if (old === next)
|
|
27
|
+
return;
|
|
28
|
+
if (n === "tasks")
|
|
29
|
+
this.data = null;
|
|
30
|
+
if (this.isConnected)
|
|
31
|
+
this.render();
|
|
32
|
+
}
|
|
33
|
+
get tasks() {
|
|
34
|
+
if (this.data)
|
|
35
|
+
return this.data;
|
|
36
|
+
return this.norm(jsonAttr(this, "tasks", []));
|
|
37
|
+
}
|
|
38
|
+
set tasks(v) {
|
|
39
|
+
this.data = this.norm(v ?? []);
|
|
40
|
+
if (this.isConnected)
|
|
41
|
+
this.render();
|
|
42
|
+
}
|
|
43
|
+
norm(list) {
|
|
44
|
+
return list.map((t) => ({
|
|
45
|
+
id: String(t.id), name: t.name, start: mid(dt(t.start) ?? new Date()), end: mid(dt(t.end) ?? dt(t.start) ?? new Date()),
|
|
46
|
+
progress: Math.max(0, Math.min(100, t.progress ?? 0)), color: t.color, dependsOn: t.dependsOn ?? [], milestone: !!t.milestone,
|
|
47
|
+
}));
|
|
48
|
+
}
|
|
49
|
+
render() {
|
|
50
|
+
const G = msg().gantt;
|
|
51
|
+
const tasks = this.tasks;
|
|
52
|
+
this.data = tasks;
|
|
53
|
+
const today = mid(dt(this.getAttribute("today")) ?? new Date());
|
|
54
|
+
const from = dt(this.getAttribute("from")), to = dt(this.getAttribute("to"));
|
|
55
|
+
const a = from ? mid(from) : add(new Date(Math.min(...tasks.map((t) => t.start.getTime()), today.getTime())), -3);
|
|
56
|
+
const b = to ? mid(to) : add(new Date(Math.max(...tasks.map((t) => t.end.getTime()), today.getTime())), 5);
|
|
57
|
+
const days = diff(a, b) + 1;
|
|
58
|
+
const holidays = bool(this, "holidays", true);
|
|
59
|
+
const editable = bool(this, "editable");
|
|
60
|
+
const { months } = calendarNames();
|
|
61
|
+
const fmt = (d) => formatJalali(d, { locale: lang(), digits: digitsOf(this) });
|
|
62
|
+
const label = this.getAttribute("label") ?? G.label;
|
|
63
|
+
let daysHtml = "";
|
|
64
|
+
const offIdx = [];
|
|
65
|
+
const runs = [];
|
|
66
|
+
const todayIdx = diff(a, today);
|
|
67
|
+
for (let i = 0; i < days; i++) {
|
|
68
|
+
const d = add(a, i), j = toJalali(d);
|
|
69
|
+
const off = d.getDay() === 5 || (holidays && !!getIranHoliday(d));
|
|
70
|
+
if (off)
|
|
71
|
+
offIdx.push(i);
|
|
72
|
+
const key = `${j.jy}-${j.jm}`;
|
|
73
|
+
const last = runs[runs.length - 1];
|
|
74
|
+
if (last?.key === key)
|
|
75
|
+
last.span++;
|
|
76
|
+
else
|
|
77
|
+
runs.push({ key, label: `${months[j.jm - 1]} ${num(this, j.jy)}`, span: 1 });
|
|
78
|
+
daysHtml += `<span class="k-gantt__day"${off ? " data-off" : ""}${i === todayIdx ? " data-today" : ""}${j.jd === 1 ? " data-first" : ""}>${num(this, j.jd)}</span>`;
|
|
79
|
+
}
|
|
80
|
+
const monthsHtml = runs.map((r) => `<span class="k-gantt__month" style="grid-column: span ${r.span}">${esc(r.label)}</span>`).join("");
|
|
81
|
+
const byId = new Map(tasks.map((t, i) => [t.id, { t, i }]));
|
|
82
|
+
const offHtml = offIdx.map((i) => `<span class="k-gantt__off" style="grid-column: ${i + 1}" aria-hidden="true"></span>`).join("");
|
|
83
|
+
const rows = tasks.map((t, row) => {
|
|
84
|
+
const s = diff(a, t.start), len = t.milestone ? 1 : diff(t.start, t.end) + 1;
|
|
85
|
+
const deps = t.dependsOn.map((x) => byId.get(x)).filter(Boolean);
|
|
86
|
+
const desc = [G.bar(t.name, fmt(t.start), fmt(t.end), num(this, t.progress)), ...deps.map((d) => G.dependsOn(d.t.name))].join(msg().common.comma);
|
|
87
|
+
const depHtml = deps.map((d) => {
|
|
88
|
+
const fromIdx = diff(a, d.t.end) + 1, up = d.i - row;
|
|
89
|
+
return `<span class="k-gantt__dep" aria-hidden="true"${fromIdx > s ? " data-backward" : ""}${up > 0 ? " data-below" : ""} style="--from:${fromIdx};--to:${s};--rows:${Math.abs(up)}"></span>`;
|
|
90
|
+
}).join("");
|
|
91
|
+
return `<div class="k-gantt__row" role="row" aria-rowindex="${row + 2}">
|
|
92
|
+
<div class="k-gantt__name" role="rowheader"><span class="k-gantt__dot"${t.color ? ` style="background:${esc(t.color)}"` : ""} aria-hidden="true"></span><span class="k-gantt__label">${esc(t.name)}</span><span class="k-gantt__len">${esc(G.days(num(this, len)))}</span></div>
|
|
93
|
+
<div class="k-gantt__track" role="cell">${offHtml}${depHtml}<button type="button" class="k-gantt__bar" data-id="${esc(t.id)}"${t.milestone ? " data-milestone" : ""}${t.progress >= 100 ? " data-done" : ""} style="--start:${s};--len:${len};--progress:${t.progress}%${t.color ? `;--k-gantt-color:${esc(t.color)}` : ""}" aria-label="${esc(desc)}"${editable ? ` aria-describedby="${this.id || "k"}-gantt-hint"` : ""}>${t.milestone ? "" : `<span class="k-gantt__fill" aria-hidden="true"></span><span class="k-gantt__text" aria-hidden="true">${esc(t.name)}</span>${editable ? '<span class="k-gantt__grip" aria-hidden="true"></span>' : ""}`}</button></div>
|
|
94
|
+
</div>`;
|
|
95
|
+
}).join("");
|
|
96
|
+
this.innerHTML = `<div class="k-gantt" style="--k-gantt-days:${days}">
|
|
97
|
+
<div class="k-gantt__scroll" role="region" aria-label="${esc(label)}" tabindex="0">
|
|
98
|
+
<div class="k-gantt__grid" role="table" aria-label="${esc(label)}" aria-rowcount="${tasks.length + 1}">
|
|
99
|
+
<div class="k-gantt__head" role="row"><div class="k-gantt__corner" role="columnheader">${esc(this.getAttribute("task-header") ?? G.task)}</div><div class="k-gantt__timehead" role="columnheader" aria-label="${esc(`${fmt(a)} – ${fmt(b)}`)}"><div class="k-gantt__months" aria-hidden="true">${monthsHtml}</div><div class="k-gantt__days" aria-hidden="true">${daysHtml}</div></div></div>
|
|
100
|
+
${rows}
|
|
101
|
+
${todayIdx >= 0 && todayIdx < days ? `<span class="k-gantt__now" style="--today:${todayIdx}" aria-hidden="true"><span>${esc(G.today)}</span></span>` : ""}
|
|
102
|
+
</div>
|
|
103
|
+
</div>
|
|
104
|
+
${editable ? `<span class="k-sr-only" id="${this.id || "k"}-gantt-hint">${esc(G.hint)}</span>` : ""}
|
|
105
|
+
<span class="k-sr-only" aria-live="polite"></span>
|
|
106
|
+
</div>`;
|
|
107
|
+
if (editable)
|
|
108
|
+
this.wire();
|
|
109
|
+
}
|
|
110
|
+
change(id, start, end) {
|
|
111
|
+
const t = this.data.find((x) => x.id === id);
|
|
112
|
+
if (!t)
|
|
113
|
+
return;
|
|
114
|
+
if (end < start)
|
|
115
|
+
end = start;
|
|
116
|
+
t.start = start;
|
|
117
|
+
t.end = end;
|
|
118
|
+
const fmt = (d) => formatJalali(d, { locale: lang(), digits: digitsOf(this) });
|
|
119
|
+
const live = msg().gantt.moved(t.name, fmt(start), fmt(end));
|
|
120
|
+
this.render();
|
|
121
|
+
[...this.querySelectorAll(".k-gantt__bar")].find((b) => b.dataset.id === id)?.focus();
|
|
122
|
+
this.querySelector(".k-gantt > [aria-live]").textContent = live;
|
|
123
|
+
emit(this, "kashi-change", { id, start, end });
|
|
124
|
+
}
|
|
125
|
+
wire() {
|
|
126
|
+
this.querySelectorAll(".k-gantt__bar").forEach((bar) => {
|
|
127
|
+
const id = bar.dataset.id;
|
|
128
|
+
const t = () => this.data.find((x) => x.id === id);
|
|
129
|
+
bar.addEventListener("keydown", (e) => {
|
|
130
|
+
if (e.key !== "ArrowLeft" && e.key !== "ArrowRight")
|
|
131
|
+
return;
|
|
132
|
+
e.preventDefault();
|
|
133
|
+
const step = (e.key === "ArrowLeft" ? 1 : -1) * (isRtl(bar) ? 1 : -1);
|
|
134
|
+
const k = t();
|
|
135
|
+
if (e.shiftKey && !k.milestone)
|
|
136
|
+
this.change(id, k.start, add(k.end, step));
|
|
137
|
+
else
|
|
138
|
+
this.change(id, add(k.start, step), add(k.end, step));
|
|
139
|
+
});
|
|
140
|
+
bar.addEventListener("pointerdown", (e) => {
|
|
141
|
+
if (e.button !== 0)
|
|
142
|
+
return;
|
|
143
|
+
bar.setPointerCapture(e.pointerId);
|
|
144
|
+
const r = bar.getBoundingClientRect(), rtl = isRtl(bar), k = t();
|
|
145
|
+
const edge = rtl ? e.clientX - r.left : r.right - e.clientX;
|
|
146
|
+
const len = k.milestone ? 1 : diff(k.start, k.end) + 1;
|
|
147
|
+
this.drag = { id, x: e.clientX, kind: !k.milestone && edge < 10 ? "end" : "move", start: k.start, end: k.end, px: r.width / len, dir: rtl ? -1 : 1, moved: false, delta: 0 };
|
|
148
|
+
});
|
|
149
|
+
bar.addEventListener("pointermove", (e) => {
|
|
150
|
+
const d = this.drag;
|
|
151
|
+
if (!d || d.id !== id)
|
|
152
|
+
return;
|
|
153
|
+
d.delta = Math.round(((e.clientX - d.x) * d.dir) / d.px);
|
|
154
|
+
if (d.delta)
|
|
155
|
+
d.moved = true;
|
|
156
|
+
if (!d.moved)
|
|
157
|
+
return;
|
|
158
|
+
bar.setAttribute("data-dragging", "");
|
|
159
|
+
const start = d.kind === "move" ? add(d.start, d.delta) : d.start;
|
|
160
|
+
const end = d.kind === "move" ? add(d.end, d.delta) : add(d.end, Math.max(d.delta, -diff(d.start, d.end)));
|
|
161
|
+
bar.style.transform = `translateX(${(d.kind === "move" ? d.delta : 0) * d.px * d.dir}px)`;
|
|
162
|
+
if (d.kind === "end")
|
|
163
|
+
bar.style.inlineSize = `calc(${diff(start, end) + 1} * var(--_day) - 4px)`;
|
|
164
|
+
});
|
|
165
|
+
bar.addEventListener("pointerup", () => {
|
|
166
|
+
const d = this.drag;
|
|
167
|
+
this.drag = null;
|
|
168
|
+
if (!d?.moved)
|
|
169
|
+
return;
|
|
170
|
+
const start = d.kind === "move" ? add(d.start, d.delta) : d.start;
|
|
171
|
+
const end = d.kind === "move" ? add(d.end, d.delta) : add(d.end, Math.max(d.delta, -diff(d.start, d.end)));
|
|
172
|
+
this.change(id, start, end);
|
|
173
|
+
});
|
|
174
|
+
bar.addEventListener("pointercancel", () => { this.drag = null; this.render(); });
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
KashiGantt.observedAttributes = ["tasks", "from", "to", "today", "editable", "holidays", "label", "task-header"];
|
|
179
|
+
define("kashi-gantt", KashiGantt, "block");
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { KashiCardNumber, KashiIban, KashiLandline, KashiLegalId, KashiMobile, KashiNationalId, KashiPostalCode, KashiPrice, KashiSayad, KashiEconomicCode, KashiTaxId } from "./inputs.js";
|
|
1
|
+
import { KashiCardNumber, KashiIban, KashiLandline, KashiLegalId, KashiMobile, KashiNationalId, KashiPostalCode, KashiPrice, KashiSayad, KashiEconomicCode, KashiTaxId, KashiBillId, KashiPaymentId } from "./inputs.js";
|
|
2
2
|
import { KashiOtp } from "./fields.js";
|
|
3
3
|
import { KashiCitySelect, KashiCombobox, KashiProvinceSelect } from "./combobox.js";
|
|
4
4
|
import { KashiAddressForm, KashiIranMap } from "./map.js";
|
|
@@ -28,7 +28,11 @@ import { KashiRichText } from "./rich-text.js";
|
|
|
28
28
|
import { KashiForm } from "./validate.js";
|
|
29
29
|
import { KashiBankCard, KashiReceipt, KashiDateTile } from "./cards.js";
|
|
30
30
|
import { KashiBusinessHours } from "./hours.js";
|
|
31
|
-
|
|
31
|
+
import { KashiSignaturePad, KashiImageCropper } from "./capture.js";
|
|
32
|
+
import { KashiGantt } from "./gantt.js";
|
|
33
|
+
import { KashiInvoice } from "./invoice.js";
|
|
34
|
+
import { KashiVirtualList, KashiInfiniteScroll } from "./lists.js";
|
|
35
|
+
export { KashiCardNumber, KashiIban, KashiLandline, KashiLegalId, KashiMobile, KashiNationalId, KashiPostalCode, KashiPrice, KashiSayad, KashiEconomicCode, KashiTaxId, KashiBillId, KashiPaymentId, KashiOtp, KashiProvinceSelect, KashiCombobox, KashiCitySelect, KashiIranMap, KashiAddressForm, KashiCalendar, KashiDatePicker, KashiTimePicker, KashiTimeClock, KashiCountdown, KashiDate, KashiMoney, KashiRelativeTime, KashiCopyButton, KashiDialog, KashiTabs, KashiTooltip, KashiToaster, toast, KashiDropdownMenu, KashiPopover, KashiTagInput, KashiNumberInput, KashiRating, KashiPagination, KashiDataTable, KashiMultiSelect, KashiSlider, KashiChipGroup, KashiPasswordStrength, KashiPersianTextarea, KashiKeyboardFix, KashiTimeInput, KashiPlateInput, KashiInlineEdit, KashiDateRangePicker, KashiMonthPicker, KashiFileUpload, KashiColorPicker, KashiBarChart, KashiLineChart, KashiPieChart, KashiBarList, KashiProportionBar, KashiSparkline, KashiActivityHeatmap, KashiCommandPalette, KashiContextMenu, KashiCarousel, KashiTreeView, KashiTour, KashiSplitter, KashiSideNav, KashiInput, KashiTextarea, KashiBanner, KashiAppointmentPicker, KashiPriceRange, KashiSwatchGroup, KashiSearchSuggest, KashiBadge, KashiAvatar, KashiAvatarGroup, KashiDivider, KashiSkeleton, KashiCard, KashiEmptyState, KashiStatCard, KashiAlert, KashiMeter, KashiProgress, KashiTimeline, KashiStepper, KashiButton, KashiButtonGroup, KashiSegmentedControl, KashiBreadcrumb, KashiAccordion, KashiCheckbox, KashiSwitch, KashiRadioGroup, KashiSelect, KashiDrawer, KashiBottomSheet, KashiNavbar, KashiNotificationList, KashiNotificationCenter, KashiChat, KashiChatMessage, KashiTypingIndicator, KashiChatComposer, KashiStreamingText, KashiCodeBlock, KashiSortable, KashiKanban, KashiScheduler, KashiGallery, KashiQrCode, KashiRichText, KashiForm, KashiBankCard, KashiReceipt, KashiDateTile, KashiBusinessHours, KashiSignaturePad, KashiImageCropper, KashiGantt, KashiInvoice, KashiVirtualList, KashiInfiniteScroll, };
|
|
32
36
|
export { KashiDigitsInput } from "./inputs.js";
|
|
33
37
|
/** زبان متنهای داخلی همهٔ عنصرها: setLocale("en") */
|
|
34
38
|
export { setLocale } from "./base.js";
|
|
@@ -43,10 +47,13 @@ export type { SelectOption } from "./choice.js";
|
|
|
43
47
|
export type { NotificationItem } from "./sheets.js";
|
|
44
48
|
export type { SchedulerEvent } from "./work.js";
|
|
45
49
|
export type { GalleryImage } from "./media.js";
|
|
50
|
+
export type { GanttTaskInput } from "./gantt.js";
|
|
51
|
+
export type { InvoiceData, InvoicePartyData, InvoiceItemData } from "./invoice.js";
|
|
52
|
+
export type { CropAreaDetail } from "./capture.js";
|
|
46
53
|
export type { RichTextTool } from "./rich-text.js";
|
|
47
54
|
export type { FormRule } from "./validate.js";
|
|
48
55
|
/** نام همهٔ عنصرها؛ مثلاً برای isCustomElement در Vue */
|
|
49
|
-
export declare const KASHI_ELEMENTS: readonly ["kashi-national-id", "kashi-legal-id", "kashi-mobile", "kashi-landline", "kashi-card-number", "kashi-iban", "kashi-postal-code", "kashi-price", "kashi-otp", "kashi-combobox", "kashi-province-select", "kashi-city-select", "kashi-iran-map", "kashi-address-form", "kashi-calendar", "kashi-date-picker", "kashi-money", "kashi-date", "kashi-relative-time", "kashi-countdown", "kashi-dialog", "kashi-tabs", "kashi-tooltip", "kashi-copy-button", "kashi-toaster", "kashi-dropdown-menu", "kashi-popover", "kashi-tag-input", "kashi-number-input", "kashi-rating", "kashi-pagination", "kashi-data-table", "kashi-multi-select", "kashi-slider", "kashi-chip-group", "kashi-password-strength", "kashi-persian-textarea", "kashi-keyboard-fix", "kashi-time-input", "kashi-time-picker", "kashi-time-clock", "kashi-plate-input", "kashi-inline-edit", "kashi-date-range-picker", "kashi-month-picker", "kashi-file-upload", "kashi-color-picker", "kashi-bar-chart", "kashi-line-chart", "kashi-pie-chart", "kashi-bar-list", "kashi-proportion-bar", "kashi-sparkline", "kashi-activity-heatmap", "kashi-command-palette", "kashi-context-menu", "kashi-carousel", "kashi-tree-view", "kashi-tour", "kashi-splitter", "kashi-side-nav", "kashi-input", "kashi-textarea", "kashi-banner", "kashi-appointment-picker", "kashi-price-range", "kashi-swatch-group", "kashi-search-suggest", "kashi-sayad", "kashi-economic-code", "kashi-tax-id", "kashi-badge", "kashi-avatar", "kashi-avatar-group", "kashi-divider", "kashi-skeleton", "kashi-card", "kashi-empty-state", "kashi-stat-card", "kashi-alert", "kashi-meter", "kashi-progress", "kashi-timeline", "kashi-stepper", "kashi-button", "kashi-button-group", "kashi-segmented-control", "kashi-breadcrumb", "kashi-accordion", "kashi-checkbox", "kashi-switch", "kashi-radio-group", "kashi-select", "kashi-drawer", "kashi-bottom-sheet", "kashi-navbar", "kashi-notification-list", "kashi-notification-center", "kashi-chat", "kashi-chat-message", "kashi-typing-indicator", "kashi-chat-composer", "kashi-streaming-text", "kashi-code-block", "kashi-sortable", "kashi-kanban", "kashi-scheduler", "kashi-gallery", "kashi-qr-code", "kashi-rich-text", "kashi-form", "kashi-bank-card", "kashi-receipt", "kashi-date-tile", "kashi-business-hours"];
|
|
56
|
+
export declare const KASHI_ELEMENTS: readonly ["kashi-national-id", "kashi-legal-id", "kashi-mobile", "kashi-landline", "kashi-card-number", "kashi-iban", "kashi-postal-code", "kashi-price", "kashi-otp", "kashi-combobox", "kashi-province-select", "kashi-city-select", "kashi-iran-map", "kashi-address-form", "kashi-calendar", "kashi-date-picker", "kashi-money", "kashi-date", "kashi-relative-time", "kashi-countdown", "kashi-dialog", "kashi-tabs", "kashi-tooltip", "kashi-copy-button", "kashi-toaster", "kashi-dropdown-menu", "kashi-popover", "kashi-tag-input", "kashi-number-input", "kashi-rating", "kashi-pagination", "kashi-data-table", "kashi-multi-select", "kashi-slider", "kashi-chip-group", "kashi-password-strength", "kashi-persian-textarea", "kashi-keyboard-fix", "kashi-time-input", "kashi-time-picker", "kashi-time-clock", "kashi-plate-input", "kashi-inline-edit", "kashi-date-range-picker", "kashi-month-picker", "kashi-file-upload", "kashi-color-picker", "kashi-bar-chart", "kashi-line-chart", "kashi-pie-chart", "kashi-bar-list", "kashi-proportion-bar", "kashi-sparkline", "kashi-activity-heatmap", "kashi-command-palette", "kashi-context-menu", "kashi-carousel", "kashi-tree-view", "kashi-tour", "kashi-splitter", "kashi-side-nav", "kashi-input", "kashi-textarea", "kashi-banner", "kashi-appointment-picker", "kashi-price-range", "kashi-swatch-group", "kashi-search-suggest", "kashi-sayad", "kashi-economic-code", "kashi-tax-id", "kashi-bill-id", "kashi-payment-id", "kashi-badge", "kashi-avatar", "kashi-avatar-group", "kashi-divider", "kashi-skeleton", "kashi-card", "kashi-empty-state", "kashi-stat-card", "kashi-alert", "kashi-meter", "kashi-progress", "kashi-timeline", "kashi-stepper", "kashi-button", "kashi-button-group", "kashi-segmented-control", "kashi-breadcrumb", "kashi-accordion", "kashi-checkbox", "kashi-switch", "kashi-radio-group", "kashi-select", "kashi-drawer", "kashi-bottom-sheet", "kashi-navbar", "kashi-notification-list", "kashi-notification-center", "kashi-chat", "kashi-chat-message", "kashi-typing-indicator", "kashi-chat-composer", "kashi-streaming-text", "kashi-code-block", "kashi-sortable", "kashi-kanban", "kashi-scheduler", "kashi-gallery", "kashi-qr-code", "kashi-rich-text", "kashi-form", "kashi-bank-card", "kashi-receipt", "kashi-date-tile", "kashi-business-hours", "kashi-signature-pad", "kashi-image-cropper", "kashi-gantt", "kashi-invoice", "kashi-virtual-list", "kashi-infinite-scroll"];
|
|
50
57
|
declare global {
|
|
51
58
|
interface HTMLElementTagNameMap {
|
|
52
59
|
"kashi-national-id": KashiNationalId;
|
|
@@ -54,6 +61,14 @@ declare global {
|
|
|
54
61
|
"kashi-sayad": KashiSayad;
|
|
55
62
|
"kashi-economic-code": KashiEconomicCode;
|
|
56
63
|
"kashi-tax-id": KashiTaxId;
|
|
64
|
+
"kashi-bill-id": KashiBillId;
|
|
65
|
+
"kashi-payment-id": KashiPaymentId;
|
|
66
|
+
"kashi-signature-pad": KashiSignaturePad;
|
|
67
|
+
"kashi-image-cropper": KashiImageCropper;
|
|
68
|
+
"kashi-gantt": KashiGantt;
|
|
69
|
+
"kashi-invoice": KashiInvoice;
|
|
70
|
+
"kashi-virtual-list": KashiVirtualList;
|
|
71
|
+
"kashi-infinite-scroll": KashiInfiniteScroll;
|
|
57
72
|
"kashi-mobile": KashiMobile;
|
|
58
73
|
"kashi-landline": KashiLandline;
|
|
59
74
|
"kashi-card-number": KashiCardNumber;
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @kashi-ui/elements — وب کامپوننتهای کاشی برای HTML، Vue، Svelte، Angular و هر فریمورک دیگر.
|
|
2
2
|
// با import کردن این فایل همهٔ عنصرها ثبت میشوند؛ استایل از @kashi-ui/css میآید.
|
|
3
|
-
import { KashiCardNumber, KashiIban, KashiLandline, KashiLegalId, KashiMobile, KashiNationalId, KashiPostalCode, KashiPrice, KashiSayad, KashiEconomicCode, KashiTaxId, } from "./inputs.js";
|
|
3
|
+
import { KashiCardNumber, KashiIban, KashiLandline, KashiLegalId, KashiMobile, KashiNationalId, KashiPostalCode, KashiPrice, KashiSayad, KashiEconomicCode, KashiTaxId, KashiBillId, KashiPaymentId, } from "./inputs.js";
|
|
4
4
|
import { KashiOtp } from "./fields.js";
|
|
5
5
|
import { KashiCitySelect, KashiCombobox, KashiProvinceSelect } from "./combobox.js";
|
|
6
6
|
import { KashiAddressForm, KashiIranMap } from "./map.js";
|
|
@@ -30,7 +30,11 @@ import { KashiRichText } from "./rich-text.js";
|
|
|
30
30
|
import { KashiForm } from "./validate.js";
|
|
31
31
|
import { KashiBankCard, KashiReceipt, KashiDateTile } from "./cards.js";
|
|
32
32
|
import { KashiBusinessHours } from "./hours.js";
|
|
33
|
-
|
|
33
|
+
import { KashiSignaturePad, KashiImageCropper } from "./capture.js";
|
|
34
|
+
import { KashiGantt } from "./gantt.js";
|
|
35
|
+
import { KashiInvoice } from "./invoice.js";
|
|
36
|
+
import { KashiVirtualList, KashiInfiniteScroll } from "./lists.js";
|
|
37
|
+
export { KashiCardNumber, KashiIban, KashiLandline, KashiLegalId, KashiMobile, KashiNationalId, KashiPostalCode, KashiPrice, KashiSayad, KashiEconomicCode, KashiTaxId, KashiBillId, KashiPaymentId, KashiOtp, KashiProvinceSelect, KashiCombobox, KashiCitySelect, KashiIranMap, KashiAddressForm, KashiCalendar, KashiDatePicker, KashiTimePicker, KashiTimeClock, KashiCountdown, KashiDate, KashiMoney, KashiRelativeTime, KashiCopyButton, KashiDialog, KashiTabs, KashiTooltip, KashiToaster, toast, KashiDropdownMenu, KashiPopover, KashiTagInput, KashiNumberInput, KashiRating, KashiPagination, KashiDataTable, KashiMultiSelect, KashiSlider, KashiChipGroup, KashiPasswordStrength, KashiPersianTextarea, KashiKeyboardFix, KashiTimeInput, KashiPlateInput, KashiInlineEdit, KashiDateRangePicker, KashiMonthPicker, KashiFileUpload, KashiColorPicker, KashiBarChart, KashiLineChart, KashiPieChart, KashiBarList, KashiProportionBar, KashiSparkline, KashiActivityHeatmap, KashiCommandPalette, KashiContextMenu, KashiCarousel, KashiTreeView, KashiTour, KashiSplitter, KashiSideNav, KashiInput, KashiTextarea, KashiBanner, KashiAppointmentPicker, KashiPriceRange, KashiSwatchGroup, KashiSearchSuggest, KashiBadge, KashiAvatar, KashiAvatarGroup, KashiDivider, KashiSkeleton, KashiCard, KashiEmptyState, KashiStatCard, KashiAlert, KashiMeter, KashiProgress, KashiTimeline, KashiStepper, KashiButton, KashiButtonGroup, KashiSegmentedControl, KashiBreadcrumb, KashiAccordion, KashiCheckbox, KashiSwitch, KashiRadioGroup, KashiSelect, KashiDrawer, KashiBottomSheet, KashiNavbar, KashiNotificationList, KashiNotificationCenter, KashiChat, KashiChatMessage, KashiTypingIndicator, KashiChatComposer, KashiStreamingText, KashiCodeBlock, KashiSortable, KashiKanban, KashiScheduler, KashiGallery, KashiQrCode, KashiRichText, KashiForm, KashiBankCard, KashiReceipt, KashiDateTile, KashiBusinessHours, KashiSignaturePad, KashiImageCropper, KashiGantt, KashiInvoice, KashiVirtualList, KashiInfiniteScroll, };
|
|
34
38
|
export { KashiDigitsInput } from "./inputs.js";
|
|
35
39
|
/** زبان متنهای داخلی همهٔ عنصرها: setLocale("en") */
|
|
36
40
|
export { setLocale } from "./base.js";
|
|
@@ -49,7 +53,7 @@ export const KASHI_ELEMENTS = [
|
|
|
49
53
|
"kashi-command-palette", "kashi-context-menu", "kashi-carousel", "kashi-tree-view", "kashi-tour", "kashi-splitter", "kashi-side-nav",
|
|
50
54
|
"kashi-input", "kashi-textarea", "kashi-banner", "kashi-appointment-picker",
|
|
51
55
|
"kashi-price-range", "kashi-swatch-group", "kashi-search-suggest",
|
|
52
|
-
"kashi-sayad", "kashi-economic-code", "kashi-tax-id",
|
|
56
|
+
"kashi-sayad", "kashi-economic-code", "kashi-tax-id", "kashi-bill-id", "kashi-payment-id",
|
|
53
57
|
"kashi-badge", "kashi-avatar", "kashi-avatar-group", "kashi-divider", "kashi-skeleton", "kashi-card", "kashi-empty-state", "kashi-stat-card", "kashi-alert", "kashi-meter", "kashi-progress", "kashi-timeline", "kashi-stepper",
|
|
54
58
|
"kashi-button", "kashi-button-group", "kashi-segmented-control", "kashi-breadcrumb", "kashi-accordion",
|
|
55
59
|
"kashi-checkbox", "kashi-switch", "kashi-radio-group", "kashi-select",
|
|
@@ -60,4 +64,5 @@ export const KASHI_ELEMENTS = [
|
|
|
60
64
|
"kashi-rich-text",
|
|
61
65
|
"kashi-form",
|
|
62
66
|
"kashi-bank-card", "kashi-receipt", "kashi-date-tile", "kashi-business-hours",
|
|
67
|
+
"kashi-signature-pad", "kashi-image-cropper", "kashi-gantt", "kashi-invoice", "kashi-virtual-list", "kashi-infinite-scroll",
|
|
63
68
|
];
|
package/dist/inputs.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ import { HTMLBase } from "./base.js";
|
|
|
4
4
|
type Meta = {
|
|
5
5
|
text: string;
|
|
6
6
|
bank?: Bank;
|
|
7
|
+
className?: string;
|
|
8
|
+
service?: string;
|
|
7
9
|
} | null;
|
|
8
10
|
interface Kind {
|
|
9
11
|
label: () => string;
|
|
@@ -118,4 +120,18 @@ export declare class KashiEconomicCode extends KashiDigitsInput {
|
|
|
118
120
|
export declare class KashiTaxId extends KashiDigitsInput {
|
|
119
121
|
protected kind: Kind;
|
|
120
122
|
}
|
|
123
|
+
/** شناسهٔ قبض: ۶ تا ۱۳ رقم با رقم کنترل استاندارد؛ نوع قبض (آب، برق، گاز…) کنار فیلد */
|
|
124
|
+
export declare class KashiBillId extends KashiDigitsInput {
|
|
125
|
+
protected kind: Kind;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* شناسهٔ پرداخت قبض: هر دو رقم کنترل بررسی میشوند (دومی با ویژگی bill-id) و مبلغ کنار فیلد میآید.
|
|
129
|
+
* unit="rial" یا "toman" (پیشفرض) واحد نمایش مبلغ است.
|
|
130
|
+
*/
|
|
131
|
+
export declare class KashiPaymentId extends KashiDigitsInput {
|
|
132
|
+
static observedAttributes: string[];
|
|
133
|
+
protected kind: Kind;
|
|
134
|
+
protected invalidText(touched: boolean): string | null;
|
|
135
|
+
protected hintText(): string | null;
|
|
136
|
+
}
|
|
121
137
|
export {};
|
package/dist/inputs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { formatCardNumber, formatIban, formatLandline, formatMobile, formatNumber, formatPostalCode, bankName, getBankByCard, getBankByIban, getLandlineProvince, getMobileOperator, operatorName, isValidCardNumber, isValidIban, isValidLandline, isValidLegalId, isValidMobile, isValidNationalId, isValidPostalCode, normalizeLandline, normalizeMobile, numberToWords, onlyDigits, toFaDigits, economicCodeType, formatSayad, isValidEconomicCode, isValidSayad, isValidTaxId, normalizeTaxId, } from "@kashi-ui/persian";
|
|
1
|
+
import { formatCardNumber, formatIban, formatLandline, formatMobile, formatNumber, formatPostalCode, bankName, getBankByCard, getBankByIban, getLandlineProvince, getMobileOperator, operatorName, isValidCardNumber, isValidIban, isValidLandline, isValidLegalId, isValidMobile, isValidNationalId, isValidPostalCode, normalizeLandline, normalizeMobile, numberToWords, onlyDigits, toFaDigits, economicCodeType, formatSayad, isValidEconomicCode, isValidSayad, isValidTaxId, normalizeTaxId, billService, formatMoney, isValidBillId, parseBill, } from "@kashi-ui/persian";
|
|
2
2
|
import { bool, define, emit, esc, fieldHTML, HTMLBase, lang, msg, setMessages, syncHidden, uid } from "./base.js";
|
|
3
3
|
const fa = (s) => toFaDigits(s);
|
|
4
4
|
/** موقعیت مکاننما پس از n رقم در متن قالببندیشده */
|
|
@@ -142,7 +142,7 @@ export class KashiDigitsInput extends HTMLBase {
|
|
|
142
142
|
addon.className = "k-input__addon";
|
|
143
143
|
addon.innerHTML = meta.bank
|
|
144
144
|
? `<span class="k-bank" id="${metaId}">${esc(meta.text)}</span>`
|
|
145
|
-
: `<span class="k-input__meta" id="${metaId}">${esc(meta.text)}</span>`;
|
|
145
|
+
: `<span class="k-input__meta${meta.className ? ` ${meta.className}` : ""}"${meta.service ? ` data-service="${meta.service}"` : ""} id="${metaId}">${esc(meta.text)}</span>`;
|
|
146
146
|
box.append(addon);
|
|
147
147
|
if (meta.bank && bool(this, "bank-logo", true))
|
|
148
148
|
this.loadLogo(meta.bank, addon.firstElementChild);
|
|
@@ -417,8 +417,68 @@ export class KashiTaxId extends KashiDigitsInput {
|
|
|
417
417
|
};
|
|
418
418
|
}
|
|
419
419
|
}
|
|
420
|
+
/** شناسهٔ قبض: ۶ تا ۱۳ رقم با رقم کنترل استاندارد؛ نوع قبض (آب، برق، گاز…) کنار فیلد */
|
|
421
|
+
export class KashiBillId extends KashiDigitsInput {
|
|
422
|
+
constructor() {
|
|
423
|
+
super(...arguments);
|
|
424
|
+
this.kind = {
|
|
425
|
+
label: () => msg().persianInput["bill-id"],
|
|
426
|
+
maxDigits: 13,
|
|
427
|
+
format: (d) => d,
|
|
428
|
+
normalize: (d) => d.replace(/^0+/, ""),
|
|
429
|
+
valid: (d) => isValidBillId(d),
|
|
430
|
+
invalidMessage: () => msg().invalid.billId,
|
|
431
|
+
placeholder: { fa: "۰۰۰۰۰۰۰۰۰۰۰۰۰", latin: "0000000000000" },
|
|
432
|
+
digits: "fa",
|
|
433
|
+
meta: (d) => {
|
|
434
|
+
const s = isValidBillId(d) ? billService(d) : null;
|
|
435
|
+
return s ? { text: msg().bill.service[s], className: "k-bill__service", service: s } : null;
|
|
436
|
+
},
|
|
437
|
+
detail: (d) => ({ service: isValidBillId(d) ? billService(d) : null }),
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* شناسهٔ پرداخت قبض: هر دو رقم کنترل بررسی میشوند (دومی با ویژگی bill-id) و مبلغ کنار فیلد میآید.
|
|
443
|
+
* unit="rial" یا "toman" (پیشفرض) واحد نمایش مبلغ است.
|
|
444
|
+
*/
|
|
445
|
+
export class KashiPaymentId extends KashiDigitsInput {
|
|
446
|
+
constructor() {
|
|
447
|
+
super(...arguments);
|
|
448
|
+
this.kind = {
|
|
449
|
+
label: () => msg().persianInput["payment-id"],
|
|
450
|
+
maxDigits: 13,
|
|
451
|
+
format: (d) => d,
|
|
452
|
+
normalize: (d) => d.replace(/^0+/, ""),
|
|
453
|
+
valid: (d) => parseBill(this.getAttribute("bill-id") ?? "", d) !== null,
|
|
454
|
+
invalidMessage: () => msg().invalid.paymentId,
|
|
455
|
+
placeholder: { fa: "۰۰۰۰۰۰۰۰", latin: "00000000" },
|
|
456
|
+
digits: "fa",
|
|
457
|
+
meta: (d, host) => {
|
|
458
|
+
const info = parseBill(host.getAttribute("bill-id") ?? "", d);
|
|
459
|
+
if (!info)
|
|
460
|
+
return null;
|
|
461
|
+
const unit = host.getAttribute("unit") === "rial" ? "rial" : "toman";
|
|
462
|
+
return { text: formatMoney(info.amount, { from: "rial", unit, locale: lang(), digits: this.digits }), className: "k-bill__amount" };
|
|
463
|
+
},
|
|
464
|
+
detail: (d) => ({ info: parseBill(this.getAttribute("bill-id") ?? "", d) }),
|
|
465
|
+
};
|
|
466
|
+
}
|
|
467
|
+
invalidText(touched) {
|
|
468
|
+
// تا شناسهٔ قبض معتبر نیامده، خطای شناسهٔ پرداخت نشان نده
|
|
469
|
+
if (!isValidBillId(this.getAttribute("bill-id") ?? ""))
|
|
470
|
+
return null;
|
|
471
|
+
return super.invalidText(touched);
|
|
472
|
+
}
|
|
473
|
+
hintText() {
|
|
474
|
+
return this.getAttribute("hint") ?? (isValidBillId(this.getAttribute("bill-id") ?? "") ? null : msg().bill.needBill);
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
KashiPaymentId.observedAttributes = [...KashiDigitsInput.observedAttributes, "bill-id", "unit"];
|
|
420
478
|
define("kashi-national-id", KashiNationalId, "block");
|
|
421
479
|
define("kashi-sayad", KashiSayad, "block");
|
|
480
|
+
define("kashi-bill-id", KashiBillId, "block");
|
|
481
|
+
define("kashi-payment-id", KashiPaymentId, "block");
|
|
422
482
|
define("kashi-economic-code", KashiEconomicCode, "block");
|
|
423
483
|
define("kashi-tax-id", KashiTaxId, "block");
|
|
424
484
|
define("kashi-legal-id", KashiLegalId, "block");
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { HTMLBase } from "./base.js";
|
|
2
|
+
export interface InvoicePartyData {
|
|
3
|
+
name: string;
|
|
4
|
+
economicCode?: string;
|
|
5
|
+
nationalId?: string;
|
|
6
|
+
postalCode?: string;
|
|
7
|
+
phone?: string;
|
|
8
|
+
address?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface InvoiceItemData {
|
|
11
|
+
description: string;
|
|
12
|
+
code?: string;
|
|
13
|
+
quantity: number;
|
|
14
|
+
unit?: string;
|
|
15
|
+
unitPrice: number;
|
|
16
|
+
discount?: number;
|
|
17
|
+
}
|
|
18
|
+
export interface InvoiceData {
|
|
19
|
+
variant?: "official" | "proforma";
|
|
20
|
+
number: string;
|
|
21
|
+
/** Date یا YYYY-MM-DD */
|
|
22
|
+
date: Date | string;
|
|
23
|
+
validUntil?: Date | string;
|
|
24
|
+
taxId?: string;
|
|
25
|
+
seller: InvoicePartyData;
|
|
26
|
+
buyer: InvoicePartyData;
|
|
27
|
+
items: InvoiceItemData[];
|
|
28
|
+
vatRate?: number;
|
|
29
|
+
currency?: "rial" | "toman";
|
|
30
|
+
notes?: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* صورتحساب فروش (الگوی سامانهٔ مؤدیان) یا پیشفاکتور: داده از ویژگی data (JSON) یا element.data.
|
|
34
|
+
* جمع، تخفیف، مالیات بر ارزش افزوده (vatRate، پیشفرض ۱۰)، مبلغ به حروف و جای مهر و امضا. signatures="false" و print-button="false".
|
|
35
|
+
*/
|
|
36
|
+
export declare class KashiInvoice extends HTMLBase {
|
|
37
|
+
static observedAttributes: string[];
|
|
38
|
+
private value;
|
|
39
|
+
connectedCallback(): void;
|
|
40
|
+
attributeChangedCallback(n: string, old: string | null, next: string | null): void;
|
|
41
|
+
get data(): InvoiceData | null;
|
|
42
|
+
set data(v: InvoiceData | null);
|
|
43
|
+
/** جمعها: جمع ردیفها، تخفیف، مالیات و مبلغ قابل پرداخت */
|
|
44
|
+
get totals(): {
|
|
45
|
+
subtotal: number;
|
|
46
|
+
discount: number;
|
|
47
|
+
taxable: number;
|
|
48
|
+
vat: number;
|
|
49
|
+
payable: number;
|
|
50
|
+
};
|
|
51
|
+
private render;
|
|
52
|
+
}
|
package/dist/invoice.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// صورتحساب رسمی و پیشفاکتور: همان نشانهگذاری k-invoice نسخهٔ React، آمادهٔ چاپ و PDF.
|
|
2
|
+
import { formatJalali, formatNumber, numberToWords } from "@kashi-ui/persian";
|
|
3
|
+
import { bool, define, digitsOf, esc, HTMLBase, lang, msg, num } from "./base.js";
|
|
4
|
+
import { jsonAttr, toDate } from "./parts.js";
|
|
5
|
+
const dt = (v) => (typeof v === "string" && /^\d{4}-\d{2}-\d{2}$/.test(v) ? new Date(+v.slice(0, 4), +v.slice(5, 7) - 1, +v.slice(8, 10)) : toDate(v));
|
|
6
|
+
/**
|
|
7
|
+
* صورتحساب فروش (الگوی سامانهٔ مؤدیان) یا پیشفاکتور: داده از ویژگی data (JSON) یا element.data.
|
|
8
|
+
* جمع، تخفیف، مالیات بر ارزش افزوده (vatRate، پیشفرض ۱۰)، مبلغ به حروف و جای مهر و امضا. signatures="false" و print-button="false".
|
|
9
|
+
*/
|
|
10
|
+
export class KashiInvoice extends HTMLBase {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments);
|
|
13
|
+
this.value = null;
|
|
14
|
+
}
|
|
15
|
+
connectedCallback() {
|
|
16
|
+
this.render();
|
|
17
|
+
}
|
|
18
|
+
attributeChangedCallback(n, old, next) {
|
|
19
|
+
if (old === next)
|
|
20
|
+
return;
|
|
21
|
+
if (n === "data")
|
|
22
|
+
this.value = null;
|
|
23
|
+
if (this.isConnected)
|
|
24
|
+
this.render();
|
|
25
|
+
}
|
|
26
|
+
get data() {
|
|
27
|
+
return this.value ?? jsonAttr(this, "data", null);
|
|
28
|
+
}
|
|
29
|
+
set data(v) {
|
|
30
|
+
this.value = v;
|
|
31
|
+
if (this.isConnected)
|
|
32
|
+
this.render();
|
|
33
|
+
}
|
|
34
|
+
/** جمعها: جمع ردیفها، تخفیف، مالیات و مبلغ قابل پرداخت */
|
|
35
|
+
get totals() {
|
|
36
|
+
const d = this.data;
|
|
37
|
+
const items = d?.items ?? [];
|
|
38
|
+
const subtotal = items.reduce((s, i) => s + i.quantity * i.unitPrice, 0);
|
|
39
|
+
const discount = items.reduce((s, i) => s + (i.discount ?? 0), 0);
|
|
40
|
+
const taxable = subtotal - discount;
|
|
41
|
+
const vat = Math.round((taxable * (d?.vatRate ?? 10)) / 100);
|
|
42
|
+
return { subtotal, discount, taxable, vat, payable: taxable + vat };
|
|
43
|
+
}
|
|
44
|
+
render() {
|
|
45
|
+
const d = this.data;
|
|
46
|
+
if (!d) {
|
|
47
|
+
this.innerHTML = "";
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const I = msg().invoice;
|
|
51
|
+
const digits = digitsOf(this);
|
|
52
|
+
const money = (v) => formatNumber(v, { digits });
|
|
53
|
+
const date = (v) => { const x = dt(v); return x ? formatJalali(x, { locale: lang(), digits }) : ""; };
|
|
54
|
+
const t = this.totals;
|
|
55
|
+
const unit = (d.currency ?? "rial") === "rial" ? I.rial : I.toman;
|
|
56
|
+
const hasDiscount = d.items.some((i) => i.discount);
|
|
57
|
+
const row = (k, v, ltr = false, wide = false) => (v ? `<div${wide ? ' class="k-invoice__wide"' : ""}><dt>${esc(k)}</dt><dd${ltr ? ' class="k-invoice__num"' : ""}>${esc(ltr ? num(this, v) : v)}</dd></div>` : "");
|
|
58
|
+
const party = (title, p) => `<section class="k-invoice__party" aria-label="${esc(title)}"><h3 class="k-invoice__party-title">${esc(title)}</h3><dl class="k-invoice__dl">${row(I.name, p.name)}${row(I.economicCode, p.economicCode, true)}${row(I.nationalId, p.nationalId, true)}${row(I.postal, p.postalCode, true)}${row(I.phone, p.phone, true)}${row(I.address, p.address, false, true)}</dl></section>`;
|
|
59
|
+
const variant = d.variant ?? "official";
|
|
60
|
+
const titleId = `${this.id || "kashi"}-invoice-title`;
|
|
61
|
+
this.innerHTML = `<article class="k-invoice" data-variant="${variant}" aria-labelledby="${titleId}">
|
|
62
|
+
<header class="k-invoice__head"><h2 class="k-invoice__title" id="${titleId}">${esc(variant === "proforma" ? I.proforma : I.official)}</h2>
|
|
63
|
+
<dl class="k-invoice__meta"><div><dt>${esc(I.number)}</dt><dd>${esc(num(this, d.number))}</dd></div><div><dt>${esc(I.date)}</dt><dd>${esc(date(d.date))}</dd></div>${variant === "proforma" && d.validUntil ? `<div><dt>${esc(I.validUntil)}</dt><dd>${esc(date(d.validUntil))}</dd></div>` : ""}${d.taxId ? `<div><dt>${esc(I.taxId)}</dt><dd dir="ltr" class="k-invoice__mono">${esc(d.taxId)}</dd></div>` : ""}</dl></header>
|
|
64
|
+
<div class="k-invoice__parties">${party(I.seller, d.seller)}${party(I.buyer, d.buyer)}</div>
|
|
65
|
+
<div class="k-invoice__table-wrap" role="region" tabindex="0" aria-label="${esc(I.description)}"><table class="k-invoice__table"><thead><tr><th scope="col" class="k-invoice__num-col">${esc(I.row)}</th><th scope="col">${esc(I.description)}</th><th scope="col" class="k-invoice__n">${esc(I.quantity)}</th><th scope="col" class="k-invoice__n">${esc(I.unitPrice)}</th>${hasDiscount ? `<th scope="col" class="k-invoice__n">${esc(I.discount)}</th>` : ""}<th scope="col" class="k-invoice__n">${esc(I.lineTotal)}</th></tr></thead><tbody>${d.items.map((it, i) => `<tr><td class="k-invoice__num-col">${num(this, i + 1)}</td><td>${esc(it.description)}${it.code ? `<span class="k-invoice__code" dir="ltr">${esc(num(this, it.code))}</span>` : ""}</td><td class="k-invoice__n">${money(it.quantity)}${it.unit ? `<span class="k-invoice__unit"> ${esc(it.unit)}</span>` : ""}</td><td class="k-invoice__n">${money(it.unitPrice)}</td>${hasDiscount ? `<td class="k-invoice__n">${it.discount ? money(it.discount) : "—"}</td>` : ""}<td class="k-invoice__n">${money(it.quantity * it.unitPrice - (it.discount ?? 0))}</td></tr>`).join("")}</tbody></table></div>
|
|
66
|
+
<div class="k-invoice__summary"><dl class="k-invoice__totals"><div><dt>${esc(I.subtotal)}</dt><dd>${money(t.subtotal)}</dd></div>${t.discount ? `<div><dt>${esc(I.totalDiscount)}</dt><dd>${money(t.discount)}</dd></div>` : ""}<div><dt>${esc(I.vat(num(this, d.vatRate ?? 10)))}</dt><dd>${money(t.vat)}</dd></div><div class="k-invoice__payable"><dt>${esc(I.payable)}</dt><dd>${money(t.payable)} <span class="k-invoice__cur">${esc(unit)}</span></dd></div></dl><p class="k-invoice__words">${esc(I.inWords(numberToWords(t.payable, { locale: lang() }), unit))}</p></div>
|
|
67
|
+
${d.notes ? `<section class="k-invoice__notes"><h3 class="k-invoice__party-title">${esc(I.notes)}</h3><div>${esc(d.notes)}</div></section>` : ""}
|
|
68
|
+
${bool(this, "signatures", true) ? `<div class="k-invoice__signs"><div class="k-invoice__sign">${esc(I.sellerSign)}</div><div class="k-invoice__sign">${esc(I.buyerSign)}</div></div>` : ""}
|
|
69
|
+
${bool(this, "print-button", true) ? `<button type="button" class="k-btn k-btn--secondary k-btn--sm k-invoice__print"><svg viewBox="0 0 20 20" aria-hidden="true" width="16" height="16"><path d="M5.5 7.5V3h9v4.5M5.5 14H4a1.5 1.5 0 0 1-1.5-1.5v-3.5A1.5 1.5 0 0 1 4 7.5h12a1.5 1.5 0 0 1 1.5 1.5v3.5A1.5 1.5 0 0 1 16 14h-1.5M5.5 11.5h9V17h-9z" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/></svg>${esc(I.print)}</button>` : ""}
|
|
70
|
+
</article>`;
|
|
71
|
+
this.querySelector(".k-invoice__print")?.addEventListener("click", () => print());
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
KashiInvoice.observedAttributes = ["data", "signatures", "print-button"];
|
|
75
|
+
define("kashi-invoice", KashiInvoice, "block");
|