@dcs-tech/ui 0.8.0 → 0.9.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.
@@ -11,8 +11,8 @@ var e = Object.defineProperty, t = (t, n) => {
11
11
  async function i(e, t) {
12
12
  if (t.signal?.aborted) throw r();
13
13
  switch (e.kind) {
14
- case "xlsx": return f(e.workbook, t);
15
- case "pdf": return g(e, t);
14
+ case "xlsx": return m(e.workbook, t);
15
+ case "pdf": return v(e, t);
16
16
  default: throw Error(`Unknown file task: ${e.kind}`);
17
17
  }
18
18
  }
@@ -27,7 +27,13 @@ async function o() {
27
27
  if (!t) throw Error("ExcelJS did not load");
28
28
  return t;
29
29
  }
30
- async function s() {
30
+ var s = null;
31
+ function c() {
32
+ return s ||= l().catch((e) => {
33
+ throw s = null, e;
34
+ }), s;
35
+ }
36
+ async function l() {
31
37
  let e = await import("pdfmake/build/pdfmake.js"), t = [
32
38
  e.default?.default,
33
39
  e.default,
@@ -35,38 +41,48 @@ async function s() {
35
41
  a.pdfMake
36
42
  ].find((e) => e && typeof e.createPdf == "function");
37
43
  if (!t) throw Error("pdfmake did not load");
38
- let n = await import("pdfmake/build/vfs_fonts.js");
44
+ let n, r = "pdfMake" in a, i = r ? a.pdfMake : a.pdfMake = {}, o = i?.addVirtualFileSystem;
45
+ i && (i.addVirtualFileSystem = (e) => {
46
+ n = e, o?.call(i, e);
47
+ });
48
+ let s;
49
+ try {
50
+ s = await import("pdfmake/build/vfs_fonts.js");
51
+ } finally {
52
+ r ? i && (o ? i.addVirtualFileSystem = o : delete i.addVirtualFileSystem) : delete a.pdfMake;
53
+ }
39
54
  return {
40
55
  pdfMake: t,
41
56
  vfs: [
42
- n?.default,
57
+ s?.default,
58
+ s,
59
+ s?.pdfMake?.vfs,
60
+ s?.default?.pdfMake?.vfs,
43
61
  n,
44
- n?.pdfMake?.vfs,
45
- n?.default?.pdfMake?.vfs,
46
62
  t.vfs,
47
63
  a.pdfMake?.vfs
48
64
  ].find((e) => e && e["Roboto-Regular.ttf"])
49
65
  };
50
66
  }
51
- var c = (e) => ArrayBuffer.isView(e) ? e.buffer.slice(e.byteOffset, e.byteOffset + e.byteLength) : e, l = (e) => "FF" + e.replace("#", "").toUpperCase();
52
- function u(e, t) {
67
+ var u = (e) => ArrayBuffer.isView(e) ? e.buffer.slice(e.byteOffset, e.byteOffset + e.byteLength) : e, d = (e) => "FF" + e.replace("#", "").toUpperCase();
68
+ function f(e, t) {
53
69
  if (t && ((t.bold !== void 0 || t.italic !== void 0 || t.size || t.color) && (e.font = {
54
70
  ...e.font ?? {},
55
71
  ...t.bold === void 0 ? {} : { bold: t.bold },
56
72
  ...t.italic === void 0 ? {} : { italic: t.italic },
57
73
  ...t.size ? { size: t.size } : {},
58
- ...t.color ? { color: { argb: l(t.color) } } : {}
74
+ ...t.color ? { color: { argb: d(t.color) } } : {}
59
75
  }), t.fill && (e.fill = {
60
76
  type: "pattern",
61
77
  pattern: "solid",
62
- fgColor: { argb: l(t.fill) }
78
+ fgColor: { argb: d(t.fill) }
63
79
  }), t.align && (e.alignment = {
64
80
  horizontal: t.align,
65
81
  vertical: "middle"
66
82
  }), t.numFmt && (typeof e.value == "number" || e.value instanceof Date) && (e.numFmt = t.numFmt), t.borderTop || t.borderBottom)) {
67
83
  let n = (e) => ({
68
84
  style: e.style,
69
- ...e.color ? { color: { argb: l(e.color) } } : {}
85
+ ...e.color ? { color: { argb: d(e.color) } } : {}
70
86
  });
71
87
  e.border = {
72
88
  ...t.borderTop ? { top: n(t.borderTop) } : {},
@@ -74,16 +90,16 @@ function u(e, t) {
74
90
  };
75
91
  }
76
92
  }
77
- function d(e, t, n) {
93
+ function p(e, t, n) {
78
94
  let r = e.addRow(t.values);
79
95
  t.style?.bold && (r.font = { bold: !0 }), t.merge && n > 1 && e.mergeCells(r.number, 1, r.number, n);
80
96
  let i = t.merge ? 1 : Math.max(t.values.length, 0);
81
97
  for (let e = 0; e < i; e++) {
82
98
  let n = r.getCell(e + 1);
83
- u(n, t.style), u(n, t.cells?.[e]);
99
+ f(n, t.style), f(n, t.cells?.[e]);
84
100
  }
85
101
  }
86
- async function f(e, t) {
102
+ async function m(e, t) {
87
103
  let n = new (await (o())).Workbook(), i = Math.max(1, e.sheets.reduce((e, t) => e + t.rows.length, 0)), a = Math.max(1, Math.floor(i / 50)), s = 0;
88
104
  for (let o of e.sheets) {
89
105
  let e = n.addWorksheet(o.name), c = o.columns.length;
@@ -91,61 +107,61 @@ async function f(e, t) {
91
107
  key: String(t),
92
108
  width: e.width
93
109
  }));
94
- for (let t of o.before ?? []) d(e, t, c);
95
- let f = e.addRow(o.columns.map((e) => e.header));
96
- f.font = { bold: o.headerStyle?.bold ?? !0 }, f.eachCell((e, t) => {
110
+ for (let t of o.before ?? []) p(e, t, c);
111
+ let l = e.addRow(o.columns.map((e) => e.header));
112
+ l.font = { bold: o.headerStyle?.bold ?? !0 }, l.eachCell((e, t) => {
97
113
  let n = o.columns[t - 1]?.align;
98
114
  n && (e.alignment = {
99
115
  horizontal: n,
100
116
  vertical: "middle"
101
- }), u(e, o.headerStyle);
117
+ }), f(e, o.headerStyle);
102
118
  });
103
- let p = f.number;
119
+ let u = l.number;
104
120
  o.freeze ? e.views = [{
105
121
  state: "frozen",
106
122
  ySplit: o.freeze.rows ?? 0,
107
123
  xSplit: o.freeze.cols ?? 0
108
124
  }] : o.freezeHeader !== !1 && (e.views = [{
109
125
  state: "frozen",
110
- ySplit: p
126
+ ySplit: u
111
127
  }]), o.rows.forEach((n, c) => {
112
- let d = e.addRow(n), f = o.cellStyles?.[c], p = o.stripe && c % 2 == 1;
128
+ let l = e.addRow(n), u = o.cellStyles?.[c], p = o.stripe && c % 2 == 1;
113
129
  if (o.columns.forEach((e, t) => {
114
- let n = d.getCell(t + 1);
130
+ let n = l.getCell(t + 1);
115
131
  e.numFmt && (typeof n.value == "number" || n.value instanceof Date) && (n.numFmt = e.numFmt), e.align && (n.alignment = {
116
132
  horizontal: e.align,
117
133
  vertical: "middle"
118
134
  }), p && (n.fill = {
119
135
  type: "pattern",
120
136
  pattern: "solid",
121
- fgColor: { argb: l(o.stripe) }
122
- }), u(n, e.style), u(n, f?.[t]);
137
+ fgColor: { argb: d(o.stripe) }
138
+ }), f(n, e.style), f(n, u?.[t]);
123
139
  }), ++s % a === 0) {
124
140
  if (t.signal?.aborted) throw r();
125
141
  t.progress(s / i * .9);
126
142
  }
127
143
  }), o.autoFilter && o.rows.length > 0 && (e.autoFilter = {
128
144
  from: {
129
- row: p,
145
+ row: u,
130
146
  column: 1
131
147
  },
132
148
  to: {
133
- row: p,
149
+ row: u,
134
150
  column: c
135
151
  }
136
152
  });
137
- for (let t of o.after ?? []) d(e, t, c);
153
+ for (let t of o.after ?? []) p(e, t, c);
138
154
  }
139
- let f = await n.xlsx.writeBuffer();
140
- return t.progress(1), c(f);
155
+ let c = await n.xlsx.writeBuffer();
156
+ return t.progress(1), u(c);
141
157
  }
142
- var p = { Roboto: {
158
+ var h = { Roboto: {
143
159
  normal: "Roboto-Regular.ttf",
144
160
  bold: "Roboto-Medium.ttf",
145
161
  italics: "Roboto-Italic.ttf",
146
162
  bolditalics: "Roboto-MediumItalic.ttf"
147
163
  } };
148
- function m(e) {
164
+ function g(e) {
149
165
  let t = e.hLineWidth ?? 1, n = e.edgeLineWidth ?? t;
150
166
  return {
151
167
  hLineWidth: (e, r) => e === 0 || e === (r.table.headerRows ?? 0) || e === r.table.body.length ? n : t,
@@ -162,7 +178,7 @@ function m(e) {
162
178
  }
163
179
  };
164
180
  }
165
- function h(e) {
181
+ function _(e) {
166
182
  return (t, n) => ({
167
183
  text: e.text.replace(/\{page\}/g, String(t)).replace(/\{pages\}/g, String(n)),
168
184
  ...e.font ? { font: e.font } : {},
@@ -172,7 +188,7 @@ function h(e) {
172
188
  ...e.margin ? { margin: e.margin } : {}
173
189
  });
174
190
  }
175
- async function g(e, t) {
191
+ async function v(e, t) {
176
192
  let n = t.pdfFonts ? {
177
193
  fonts: {
178
194
  ...t.pdfFonts.fonts,
@@ -184,16 +200,16 @@ async function g(e, t) {
184
200
  } : void 0
185
201
  } : e.fonts, i = e.footer ? {
186
202
  ...e.document,
187
- footer: h(e.footer)
188
- } : e.document, a = e.tableLayouts ? Object.fromEntries(Object.entries(e.tableLayouts).map(([e, t]) => [e, m(t)])) : void 0, { pdfMake: o, vfs: c } = await s();
203
+ footer: _(e.footer)
204
+ } : e.document, a = e.tableLayouts ? Object.fromEntries(Object.entries(e.tableLayouts).map(([e, t]) => [e, g(t)])) : void 0, { pdfMake: o, vfs: s } = await c();
189
205
  if (t.progress(.1), t.signal?.aborted) throw r();
190
206
  let l = {
191
- ...p,
207
+ ...h,
192
208
  ...n?.fonts ?? {}
193
209
  }, u = n?.vfs ? {
194
- ...c ?? {},
210
+ ...s ?? {},
195
211
  ...n.vfs
196
- } : c, d = await new Promise((e, t) => {
212
+ } : s, d = await new Promise((e, t) => {
197
213
  try {
198
214
  let n = o.createPdf(i, a, l, u).getStream(), r = [];
199
215
  n.on("data", (e) => r.push(e)), n.on("error", t), n.on("end", () => {
@@ -0,0 +1,269 @@
1
+ "use client";
2
+ import { Nn as e, wn as t } from "./geometry-yZmKN662.js";
3
+ import { n, t as r } from "./labels-CnqqTrne.js";
4
+ import { createContext as i, useCallback as ee, useContext as a, useEffect as o, useId as te, useLayoutEffect as s, useMemo as c, useRef as l, useState as u } from "react";
5
+ import { jsx as d, jsxs as f } from "react/jsx-runtime";
6
+ import { createPortal as ne } from "react-dom";
7
+ // src/components/Dialog/dialogOpen.tsx
8
+ var p = i(null), m = i(0), h = ({ children: e }) => {
9
+ let [t, n] = u(0), r = c(() => () => {
10
+ n((e) => e + 1);
11
+ let e = !1;
12
+ return () => {
13
+ e || (e = !0, n((e) => e - 1));
14
+ };
15
+ }, []);
16
+ return /* @__PURE__ */ d(p.Provider, {
17
+ value: r,
18
+ children: /* @__PURE__ */ d(m.Provider, {
19
+ value: t,
20
+ children: e
21
+ })
22
+ });
23
+ };
24
+ function g(e) {
25
+ let t = a(p);
26
+ o(() => e && t ? t() : void 0, [e, t]);
27
+ }
28
+ var _ = () => a(m), v = () => a(m) > 0, y = {
29
+ root: "_root_1rswg_7",
30
+ nonModal: "_nonModal_1rswg_30",
31
+ panel: "_panel_1rswg_3",
32
+ center: "_center_1rswg_41",
33
+ right: "_right_1rswg_42",
34
+ left: "_left_1rswg_43",
35
+ top: "_top_1rswg_44",
36
+ bottom: "_bottom_1rswg_45",
37
+ sm: "_sm_1rswg_86",
38
+ md: "_md_1rswg_87",
39
+ lg: "_lg_1rswg_88",
40
+ xl: "_xl_1rswg_89",
41
+ full: "_full_1rswg_90",
42
+ header: "_header_1rswg_96",
43
+ headText: "_headText_1rswg_106",
44
+ title: "_title_1rswg_108",
45
+ subtitle: "_subtitle_1rswg_114",
46
+ body: "_body_1rswg_120",
47
+ flush: "_flush_1rswg_128",
48
+ footer: "_footer_1rswg_130",
49
+ close: "_close_1rswg_141",
50
+ dialogPop: "_dialogPop_1rswg_1",
51
+ slideFromRight: "_slideFromRight_1rswg_1",
52
+ slideFromLeft: "_slideFromLeft_1rswg_1",
53
+ slideFromTop: "_slideFromTop_1rswg_1",
54
+ slideFromBottom: "_slideFromBottom_1rswg_1",
55
+ backdropIn: "_backdropIn_1rswg_1",
56
+ closing: "_closing_1rswg_168"
57
+ }, b = 0, x = null, re = (e) => {
58
+ if (typeof document < "u") {
59
+ if (b === 0) {
60
+ let t = document.body;
61
+ x = {
62
+ overflow: t.style.overflow,
63
+ paddingRight: t.style.paddingRight
64
+ };
65
+ let n = window.innerWidth - document.documentElement.clientWidth;
66
+ if (e && n > 0) {
67
+ let e = parseFloat(window.getComputedStyle(t).paddingRight) || 0;
68
+ t.style.paddingRight = `${e + n}px`;
69
+ }
70
+ t.style.overflow = "hidden";
71
+ }
72
+ b += 1;
73
+ }
74
+ }, ie = () => {
75
+ typeof document < "u" && (b = Math.max(0, b - 1), b === 0 && x && (document.body.style.overflow = x.overflow, document.body.style.paddingRight = x.paddingRight, x = null));
76
+ }, S = () => typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches, ae = /* @__PURE__ */ f("svg", {
77
+ width: "16",
78
+ height: "16",
79
+ viewBox: "0 0 24 24",
80
+ fill: "none",
81
+ stroke: "currentColor",
82
+ strokeWidth: "2",
83
+ strokeLinecap: "round",
84
+ "aria-hidden": "true",
85
+ children: [/* @__PURE__ */ d("line", {
86
+ x1: "18",
87
+ y1: "6",
88
+ x2: "6",
89
+ y2: "18"
90
+ }), /* @__PURE__ */ d("line", {
91
+ x1: "6",
92
+ y1: "6",
93
+ x2: "18",
94
+ y2: "18"
95
+ })]
96
+ }), oe = 0, C = "button:not([disabled]),a[href],input:not([disabled]):not([type=\"hidden\"]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex=\"-1\"]),[contenteditable=\"true\"]", w = ({ open: n, onClose: r, onBeforeClose: i, onEscKeyDown: a, onOverlayClick: c, onAnimationEnd: p, children: m, title: h, subtitle: _, footer: v, modal: b = !0, placement: x = "center", size: w = "md", closeOnBackdrop: T = !0, closeOnEscape: E = !0, showCloseButton: D = !0, closeIcon: O, closeIconId: k, blockScroll: A = !0, reserveScrollBarGap: j = !0, initialFocusRef: M, container: se, animationDuration: ce = 200, padded: le = !0, classNames: N = {}, styleSlots: P = {}, className: ue = "", style: de, role: fe = "dialog", id: pe, "aria-label": F, "aria-labelledby": I, "aria-describedby": L }) => {
97
+ let R = e(), z = l(null), [me, he] = u(null), B = te(), [V, H] = u(n), [ge, U] = u(!1), [W, G] = u(!1), K = l(null), q = l(n);
98
+ q.current = n;
99
+ let J = l(null), Y = S() ? 0 : ce;
100
+ g(V), o(() => {
101
+ n ? (J.current &&= (clearTimeout(J.current), null), U(!1), H(!0)) : V && (U(!0), J.current = setTimeout(() => {
102
+ z.current?.close(), H(!1), G(!1), U(!1), p?.();
103
+ }, Y));
104
+ }, [n]), o(() => () => {
105
+ J.current && clearTimeout(J.current);
106
+ }, []);
107
+ let X = ee(() => {
108
+ i && i() === !1 || r?.();
109
+ }, [i, r]);
110
+ s(() => {
111
+ let e = z.current;
112
+ if (e && V) {
113
+ if (!e.open) {
114
+ let t = document.activeElement;
115
+ K.current = t instanceof HTMLElement && t !== document.body ? t : null, b && (e.dataset.modalOrder = String(++oe)), b ? e.showModal() : e.show();
116
+ }
117
+ G(!0);
118
+ }
119
+ }, [V, b]), s(() => {
120
+ let e = z.current;
121
+ if (!e || !W) return;
122
+ if (M?.current) {
123
+ M.current.focus({ focusVisible: !0 });
124
+ return;
125
+ }
126
+ let t = document.activeElement;
127
+ t && t !== e && e.contains(t) || e.querySelector(C)?.focus();
128
+ }, [W]), s(() => () => {
129
+ let e = z.current, t = K.current;
130
+ if (!e?.open || !t) return;
131
+ let n = document.activeElement;
132
+ (!n || n === document.body || e.contains(n)) && queueMicrotask(() => {
133
+ let e = document.activeElement;
134
+ t.isConnected && (!e || e === document.body) && t.focus({ preventScroll: !0 });
135
+ });
136
+ }, []), o(() => {
137
+ if (V && A && b) return re(j), () => ie();
138
+ }, [
139
+ V,
140
+ b,
141
+ A,
142
+ j
143
+ ]), o(() => {
144
+ let e = z.current;
145
+ if (!e || !V) return;
146
+ let t = (t) => {
147
+ t.key !== "Escape" || t.defaultPrevented || t.isComposing || t.target instanceof Node && e.contains(t.target) && (t.preventDefault(), a?.(t), E && X());
148
+ }, n = (e) => {
149
+ e.preventDefault(), a?.(e), E && X();
150
+ }, r = () => {
151
+ q.current && !e.open && e.isConnected && (b ? e.showModal() : e.show(), e.querySelector(C)?.focus());
152
+ }, i = e.ownerDocument.defaultView ?? window;
153
+ return i.addEventListener("keydown", t), e.addEventListener("cancel", n), e.addEventListener("close", r), () => {
154
+ i.removeEventListener("keydown", t), e.removeEventListener("cancel", n), e.removeEventListener("close", r);
155
+ };
156
+ }, [
157
+ V,
158
+ b,
159
+ E,
160
+ X,
161
+ a
162
+ ]);
163
+ let Z = l(!1), _e = (e) => {
164
+ Z.current = e.target === z.current;
165
+ }, Q = (e) => {
166
+ let t = Z.current && e.target === z.current;
167
+ Z.current = !1, t && (c?.(e), T && X());
168
+ };
169
+ if (!V) return null;
170
+ let ve = h !== void 0 || _ !== void 0 || D, ye = I ?? (h !== void 0 && !F ? B : void 0), be = /* @__PURE__ */ d("dialog", {
171
+ ref: (e) => {
172
+ z.current = e, he(e);
173
+ },
174
+ id: pe,
175
+ "data-modal": b ? "" : void 0,
176
+ className: [
177
+ y.root,
178
+ y[x],
179
+ y[w],
180
+ b ? "" : y.nonModal,
181
+ ge ? y.closing : "",
182
+ N.root,
183
+ ue
184
+ ].filter(Boolean).join(" "),
185
+ style: {
186
+ "--dialog-anim": `${Y}ms`,
187
+ ...P.root,
188
+ ...de
189
+ },
190
+ role: fe,
191
+ "aria-label": F,
192
+ "aria-labelledby": ye,
193
+ "aria-describedby": L,
194
+ "aria-modal": b || void 0,
195
+ onPointerDown: _e,
196
+ onPointerUp: Q,
197
+ children: /* @__PURE__ */ d(t.Provider, {
198
+ value: me,
199
+ children: W && /* @__PURE__ */ f("div", {
200
+ className: [y.panel, N.panel].filter(Boolean).join(" "),
201
+ style: P.panel,
202
+ children: [
203
+ ve && /* @__PURE__ */ f("div", {
204
+ className: [y.header, N.header].filter(Boolean).join(" "),
205
+ style: P.header,
206
+ children: [/* @__PURE__ */ f("span", {
207
+ className: y.headText,
208
+ children: [h !== void 0 && /* @__PURE__ */ d("span", {
209
+ className: y.title,
210
+ id: B,
211
+ children: h
212
+ }), _ !== void 0 && /* @__PURE__ */ d("span", {
213
+ className: y.subtitle,
214
+ children: _
215
+ })]
216
+ }), D && /* @__PURE__ */ d("button", {
217
+ type: "button",
218
+ id: k,
219
+ className: [y.close, N.closeButton].filter(Boolean).join(" "),
220
+ style: P.closeButton,
221
+ onClick: X,
222
+ "aria-label": R.dialog.close,
223
+ children: O ?? ae
224
+ })]
225
+ }),
226
+ m !== void 0 && /* @__PURE__ */ d("div", {
227
+ className: [
228
+ y.body,
229
+ le ? "scroll-fade-y scroll-gutter" : `${y.flush} scroll-fade-y`,
230
+ N.body
231
+ ].filter(Boolean).join(" "),
232
+ style: P.body,
233
+ children: m
234
+ }),
235
+ v !== void 0 && /* @__PURE__ */ d("div", {
236
+ className: [y.footer, N.footer].filter(Boolean).join(" "),
237
+ style: P.footer,
238
+ children: v
239
+ })
240
+ ]
241
+ })
242
+ })
243
+ }), $ = se ?? (typeof document > "u" ? null : document.body);
244
+ return $ ? ne(be, $) : null;
245
+ };
246
+ w.displayName = "Dialog";
247
+ var T = i({
248
+ authorize: () => !0,
249
+ exportOptions: {},
250
+ serverMode: !1,
251
+ labels: r,
252
+ format: n(),
253
+ text: {
254
+ yes: r.yes,
255
+ no: r.no
256
+ }
257
+ });
258
+ function E() {
259
+ return a(T);
260
+ }
261
+ function D() {
262
+ return a(T).labels;
263
+ }
264
+ function O(e, t, n) {
265
+ return !e || e(t, n) !== !1;
266
+ }
267
+ // src/components/DataTable/layout/scrollArea.ts
268
+ var k = "dt-scroll-area scroll-fade-y scroll-gutter", A = "dt-scroll-area scroll-fade-x scroll-fade-y scroll-gutter";
269
+ export { D as a, h as c, O as i, v as l, k as n, E as o, T as r, w as s, A as t, _ as u };