neatkit 0.13.4 → 0.13.6

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.
@@ -1,426 +0,0 @@
1
- "use client";
2
- import { jsx as a, jsxs as B } from "react/jsx-runtime";
3
- import { createContext as F, forwardRef as g, Children as L, isValidElement as j, Fragment as A, cloneElement as x, createElement as M, useRef as N, useContext as V, useState as E, useEffect as Y, useCallback as X } from "react";
4
- import { a as $ } from "./reference-CXMr27nM.js";
5
- import { S as q } from "./Surface-vEFsZC12.js";
6
- import { B as G } from "./Button-CyUpMPtt.js";
7
- import { T as J } from "./Tooltip-WwAWQ_Kq.js";
8
- const T = F("body"), I = g(function(l, e) {
9
- const {
10
- align: t = "left",
11
- children: i,
12
- className: r,
13
- scope: c = "col",
14
- sticky: f = !1,
15
- ...s
16
- } = l;
17
- return /* @__PURE__ */ a(
18
- "th",
19
- {
20
- ...s,
21
- ref: e,
22
- className: ["nk-table__header-cell", r].filter(Boolean).join(" "),
23
- "data-align": t,
24
- "data-sticky": f || void 0,
25
- scope: c,
26
- children: i
27
- }
28
- );
29
- });
30
- function H(n) {
31
- for (const l of L.toArray(n)) {
32
- if (j(l) && l.type === A) {
33
- if (H(l.props.children)) return !0;
34
- continue;
35
- }
36
- return !0;
37
- }
38
- return !1;
39
- }
40
- const Q = g(
41
- function(l, e) {
42
- const {
43
- children: t,
44
- className: i,
45
- emptyColumnCount: r = 1,
46
- emptyMessage: c,
47
- ...f
48
- } = l, s = !H(t), m = Number.isFinite(r) ? Math.max(1, Math.floor(r)) : 1;
49
- return /* @__PURE__ */ a(
50
- "tbody",
51
- {
52
- ...f,
53
- ref: e,
54
- className: ["nk-table__body", i].filter(Boolean).join(" "),
55
- children: s && c !== void 0 ? /* @__PURE__ */ a("tr", { className: "nk-table__row", children: /* @__PURE__ */ a(
56
- "td",
57
- {
58
- className: "nk-table__cell nk-table__empty-cell",
59
- colSpan: m,
60
- children: /* @__PURE__ */ a("div", { className: "nk-table__empty-content", children: c })
61
- }
62
- ) }) : /* @__PURE__ */ a(T.Provider, { value: "body", children: t })
63
- }
64
- );
65
- }
66
- );
67
- function U(n, l, e) {
68
- return n === void 0 ? l : e ? e(n) : n instanceof Date ? Number.isNaN(n.getTime()) ? "Invalid Date" : n.toISOString().slice(0, 10) : typeof n == "boolean" ? n ? "Yes" : "No" : n;
69
- }
70
- function W(n) {
71
- if (typeof n == "number" || typeof n == "string")
72
- return String(n);
73
- }
74
- const D = g(
75
- function(l, e) {
76
- const {
77
- align: t = "left",
78
- children: i,
79
- className: r,
80
- format: c,
81
- title: f,
82
- truncate: s,
83
- value: m,
84
- ...h
85
- } = l, { rowTrigger: o, ...d } = h, p = U(m, i, c), u = s === void 0 ? void 0 : { maxWidth: s }, k = f ?? (s === void 0 ? void 0 : W(p));
86
- return /* @__PURE__ */ B(
87
- "td",
88
- {
89
- ...d,
90
- ref: e,
91
- className: ["nk-table__cell", r].filter(Boolean).join(" "),
92
- "data-align": t,
93
- title: k,
94
- children: [
95
- (o == null ? void 0 : o.kind) === "link" && o.linkProperties ? /* @__PURE__ */ a(
96
- "a",
97
- {
98
- ref: o.reference,
99
- "aria-label": o.ariaLabel,
100
- className: "nk-table__row-trigger",
101
- download: o.linkProperties.download,
102
- href: o.linkProperties.href,
103
- hrefLang: o.linkProperties.hrefLang,
104
- onClick: o.linkProperties.onNavigate,
105
- rel: o.linkProperties.rel,
106
- target: o.linkProperties.target
107
- }
108
- ) : null,
109
- (o == null ? void 0 : o.kind) === "button" ? /* @__PURE__ */ a(
110
- "button",
111
- {
112
- ref: o.reference,
113
- "aria-label": o.ariaLabel,
114
- className: "nk-table__row-trigger",
115
- onClick: o.onClick,
116
- type: "button"
117
- }
118
- ) : null,
119
- s !== void 0 ? /* @__PURE__ */ a("span", { className: "nk-table__truncated-content", style: u, children: p }) : p
120
- ]
121
- }
122
- );
123
- }
124
- ), Z = g(
125
- function(l, e) {
126
- const { children: t, className: i, ...r } = l;
127
- return /* @__PURE__ */ a(
128
- "tfoot",
129
- {
130
- ...r,
131
- ref: e,
132
- className: ["nk-table__foot", i].filter(Boolean).join(" "),
133
- children: /* @__PURE__ */ a(T.Provider, { value: "foot", children: t })
134
- }
135
- );
136
- }
137
- ), ee = g(
138
- function(l, e) {
139
- const { children: t, className: i, ...r } = l;
140
- return /* @__PURE__ */ a(
141
- "thead",
142
- {
143
- ...r,
144
- ref: e,
145
- className: ["nk-table__head", i].filter(Boolean).join(" "),
146
- children: /* @__PURE__ */ a(T.Provider, { value: "head", children: t })
147
- }
148
- );
149
- }
150
- ), te = [
151
- "a[href]",
152
- "audio[controls]",
153
- "button",
154
- "iframe",
155
- "input",
156
- "label",
157
- "select",
158
- "summary",
159
- "textarea",
160
- "video[controls]",
161
- "[contenteditable]:not([contenteditable='false'])"
162
- ].join(","), ne = /* @__PURE__ */ new Set([
163
- "button",
164
- "checkbox",
165
- "combobox",
166
- "grid",
167
- "link",
168
- "listbox",
169
- "menu",
170
- "menubar",
171
- "menuitem",
172
- "menuitemcheckbox",
173
- "menuitemradio",
174
- "option",
175
- "radio",
176
- "radiogroup",
177
- "scrollbar",
178
- "searchbox",
179
- "slider",
180
- "spinbutton",
181
- "switch",
182
- "tab",
183
- "tablist",
184
- "textbox",
185
- "tree",
186
- "treegrid",
187
- "treeitem"
188
- ]);
189
- function le(n, l) {
190
- var t;
191
- let e = n;
192
- for (; e && e !== l; ) {
193
- if (e.matches(te) || (((t = e.getAttribute("role")) == null ? void 0 : t.split(/\s+/)) ?? []).some((r) => ne.has(r)))
194
- return !0;
195
- e = e.parentElement;
196
- }
197
- return !1;
198
- }
199
- function oe(n, l) {
200
- let e = !1;
201
- function t(r) {
202
- return L.map(r, (c) => j(c) ? c.type === A ? x(
203
- c,
204
- void 0,
205
- t(
206
- c.props.children
207
- )
208
- ) : !e && c.type === D ? (e = !0, x(
209
- c,
210
- { rowTrigger: l }
211
- )) : c : c);
212
- }
213
- const i = t(n);
214
- return { attached: e, content: i };
215
- }
216
- function re(n) {
217
- const {
218
- "aria-label": l,
219
- icon: e,
220
- label: t,
221
- ...i
222
- } = n;
223
- return /* @__PURE__ */ a(J, { content: t, children: /* @__PURE__ */ a(
224
- G,
225
- {
226
- ...i,
227
- "aria-label": l ?? t,
228
- icon: e,
229
- shape: "rectangle",
230
- size: "small",
231
- type: "button",
232
- variant: "ghost"
233
- }
234
- ) });
235
- }
236
- function ae(n) {
237
- const { actions: l } = n;
238
- function e(t) {
239
- t.stopPropagation();
240
- }
241
- return /* @__PURE__ */ a(
242
- "td",
243
- {
244
- className: "nk-table__cell nk-table__action-cell",
245
- "data-align": "right",
246
- onClick: e,
247
- children: l.length > 0 ? /* @__PURE__ */ a("span", { className: "nk-table__action-list", children: l.map((t) => /* @__PURE__ */ M(re, { ...t, key: t.label })) }) : null
248
- }
249
- );
250
- }
251
- const ie = g(function(l, e) {
252
- const { children: t, className: i, ...r } = l;
253
- return /* @__PURE__ */ a(
254
- I,
255
- {
256
- ...r,
257
- ref: e,
258
- align: "right",
259
- className: ["nk-table__action-header-cell", i].filter(Boolean).join(" "),
260
- children: t ?? /* @__PURE__ */ a("span", { className: "nk-table__visually-hidden", children: "Row actions" })
261
- }
262
- );
263
- }), ce = g(
264
- function(l, e) {
265
- const {
266
- "aria-label": t,
267
- actions: i,
268
- children: r,
269
- className: c,
270
- download: f,
271
- href: s,
272
- hrefLang: m,
273
- onClick: h,
274
- onNavigate: o,
275
- rel: d,
276
- target: p,
277
- ...u
278
- } = l, k = N(null), C = V(T), y = s !== void 0 || h !== void 0, R = (t == null ? void 0 : t.trim()) || (s !== void 0 ? "Open row" : "Activate row");
279
- function S(b) {
280
- k.current = b;
281
- }
282
- let _;
283
- s !== void 0 ? _ = {
284
- ariaLabel: R,
285
- kind: "link",
286
- linkProperties: {
287
- download: f,
288
- href: s,
289
- hrefLang: m,
290
- onNavigate: o,
291
- rel: d,
292
- target: p
293
- },
294
- reference: S
295
- } : h !== void 0 && (_ = {
296
- ariaLabel: R,
297
- kind: "button",
298
- onClick: h,
299
- reference: S
300
- });
301
- const K = _ ? oe(r, _) : { content: r };
302
- function O(b) {
303
- if (b.defaultPrevented) return;
304
- const P = b.target;
305
- if (!(P instanceof Element) || le(P, b.currentTarget)) return;
306
- const v = k.current;
307
- if (!v) return;
308
- const w = v.ownerDocument.defaultView;
309
- if (!w) {
310
- v.click();
311
- return;
312
- }
313
- v.dispatchEvent(new w.MouseEvent("click", {
314
- altKey: b.altKey,
315
- bubbles: !0,
316
- button: b.button,
317
- buttons: b.buttons,
318
- cancelable: !0,
319
- clientX: b.clientX,
320
- clientY: b.clientY,
321
- ctrlKey: b.ctrlKey,
322
- metaKey: b.metaKey,
323
- shiftKey: b.shiftKey
324
- }));
325
- }
326
- const z = C === "head" ? /* @__PURE__ */ a(ie, {}) : /* @__PURE__ */ a(ae, { actions: i ?? [] });
327
- return /* @__PURE__ */ B(
328
- "tr",
329
- {
330
- ...u,
331
- ref: e,
332
- "aria-label": y ? void 0 : t,
333
- className: ["nk-table__row", c].filter(Boolean).join(" "),
334
- "data-interactive": y || void 0,
335
- onClick: y ? O : void 0,
336
- children: [
337
- K.content,
338
- z
339
- ]
340
- }
341
- );
342
- }
343
- );
344
- function se() {
345
- const n = N(null), l = N(null), [e, t] = E(!1), [i, r] = E(!1);
346
- Y(() => {
347
- const f = n.current, s = l.current;
348
- if (!f || !s) return;
349
- const m = f, h = s;
350
- function o() {
351
- const k = m.scrollWidth > m.clientWidth;
352
- t(k), k || r(!1);
353
- }
354
- o();
355
- const d = m.ownerDocument.defaultView;
356
- d == null || d.addEventListener("resize", o);
357
- const p = d == null ? void 0 : d.ResizeObserver, u = p ? new p(o) : void 0;
358
- return u == null || u.observe(m), u == null || u.observe(h), () => {
359
- d == null || d.removeEventListener("resize", o), u == null || u.disconnect();
360
- };
361
- }, []);
362
- function c(f) {
363
- r(e && f.currentTarget.scrollLeft > 1);
364
- }
365
- return {
366
- containerReference: n,
367
- contentReference: l,
368
- isScrollable: e,
369
- isScrolled: i,
370
- handleScroll: c
371
- };
372
- }
373
- const de = g(function(l, e) {
374
- const {
375
- "aria-label": t,
376
- children: i,
377
- className: r,
378
- containerClassName: c,
379
- frame: f = "outline",
380
- ...s
381
- } = l, {
382
- containerReference: m,
383
- contentReference: h,
384
- isScrollable: o,
385
- isScrolled: d,
386
- handleScroll: p
387
- } = se(), u = t ? `${t} scroll area` : "Scrollable table", k = X(
388
- (C) => {
389
- h.current = C, $(e, C);
390
- },
391
- [h, e]
392
- );
393
- return /* @__PURE__ */ a(
394
- q,
395
- {
396
- ref: m,
397
- "aria-label": o ? u : void 0,
398
- className: ["nk-table", c].filter(Boolean).join(" "),
399
- "data-frame": f,
400
- "data-scrolled": d || void 0,
401
- onScroll: p,
402
- role: o ? "region" : void 0,
403
- tabIndex: o ? 0 : void 0,
404
- children: /* @__PURE__ */ a(
405
- "table",
406
- {
407
- ...s,
408
- ref: k,
409
- "aria-label": t,
410
- className: ["nk-table__element", r].filter(Boolean).join(" "),
411
- children: i
412
- }
413
- )
414
- }
415
- );
416
- }), ke = Object.assign(de, {
417
- Body: Q,
418
- Cell: D,
419
- Foot: Z,
420
- HeaderCell: I,
421
- Head: ee,
422
- Row: ce
423
- });
424
- export {
425
- ke as T
426
- };
@@ -1 +0,0 @@
1
- "use client";"use strict";const a=require("react/jsx-runtime"),o=require("react"),A=require("./reference-C2guRuR0.cjs"),I=require("./Surface-BttJYSDt.cjs"),H=require("./Button-CTzvBhGH.cjs"),D=require("./Tooltip-CxcO3Vu-.cjs"),v=o.createContext("body"),w=o.forwardRef(function(r,e){const{align:t="left",children:s,className:i,scope:c="col",sticky:b=!1,...d}=r;return a.jsx("th",{...d,ref:e,className:["nk-table__header-cell",i].filter(Boolean).join(" "),"data-align":t,"data-sticky":b||void 0,scope:c,children:s})});function S(n){for(const r of o.Children.toArray(n)){if(o.isValidElement(r)&&r.type===o.Fragment){if(S(r.props.children))return!0;continue}return!0}return!1}const K=o.forwardRef(function(r,e){const{children:t,className:s,emptyColumnCount:i=1,emptyMessage:c,...b}=r,d=!S(t),h=Number.isFinite(i)?Math.max(1,Math.floor(i)):1;return a.jsx("tbody",{...b,ref:e,className:["nk-table__body",s].filter(Boolean).join(" "),children:d&&c!==void 0?a.jsx("tr",{className:"nk-table__row",children:a.jsx("td",{className:"nk-table__cell nk-table__empty-cell",colSpan:h,children:a.jsx("div",{className:"nk-table__empty-content",children:c})})}):a.jsx(v.Provider,{value:"body",children:t})})});function O(n,r,e){return n===void 0?r:e?e(n):n instanceof Date?Number.isNaN(n.getTime())?"Invalid Date":n.toISOString().slice(0,10):typeof n=="boolean"?n?"Yes":"No":n}function F(n){if(typeof n=="number"||typeof n=="string")return String(n)}const P=o.forwardRef(function(r,e){const{align:t="left",children:s,className:i,format:c,title:b,truncate:d,value:h,...p}=r,{rowTrigger:l,...u}=p,k=O(h,s,c),f=d===void 0?void 0:{maxWidth:d},g=b??(d===void 0?void 0:F(k));return a.jsxs("td",{...u,ref:e,className:["nk-table__cell",i].filter(Boolean).join(" "),"data-align":t,title:g,children:[(l==null?void 0:l.kind)==="link"&&l.linkProperties?a.jsx("a",{ref:l.reference,"aria-label":l.ariaLabel,className:"nk-table__row-trigger",download:l.linkProperties.download,href:l.linkProperties.href,hrefLang:l.linkProperties.hrefLang,onClick:l.linkProperties.onNavigate,rel:l.linkProperties.rel,target:l.linkProperties.target}):null,(l==null?void 0:l.kind)==="button"?a.jsx("button",{ref:l.reference,"aria-label":l.ariaLabel,className:"nk-table__row-trigger",onClick:l.onClick,type:"button"}):null,d!==void 0?a.jsx("span",{className:"nk-table__truncated-content",style:f,children:k}):k]})}),q=o.forwardRef(function(r,e){const{children:t,className:s,...i}=r;return a.jsx("tfoot",{...i,ref:e,className:["nk-table__foot",s].filter(Boolean).join(" "),children:a.jsx(v.Provider,{value:"foot",children:t})})}),z=o.forwardRef(function(r,e){const{children:t,className:s,...i}=r;return a.jsx("thead",{...i,ref:e,className:["nk-table__head",s].filter(Boolean).join(" "),children:a.jsx(v.Provider,{value:"head",children:t})})}),V=["a[href]","audio[controls]","button","iframe","input","label","select","summary","textarea","video[controls]","[contenteditable]:not([contenteditable='false'])"].join(","),M=new Set(["button","checkbox","combobox","grid","link","listbox","menu","menubar","menuitem","menuitemcheckbox","menuitemradio","option","radio","radiogroup","scrollbar","searchbox","slider","spinbutton","switch","tab","tablist","textbox","tree","treegrid","treeitem"]);function Y(n,r){var t;let e=n;for(;e&&e!==r;){if(e.matches(V)||(((t=e.getAttribute("role"))==null?void 0:t.split(/\s+/))??[]).some(i=>M.has(i)))return!0;e=e.parentElement}return!1}function X(n,r){let e=!1;function t(i){return o.Children.map(i,c=>o.isValidElement(c)?c.type===o.Fragment?o.cloneElement(c,void 0,t(c.props.children)):!e&&c.type===P?(e=!0,o.cloneElement(c,{rowTrigger:r})):c:c)}const s=t(n);return{attached:e,content:s}}function $(n){const{"aria-label":r,icon:e,label:t,...s}=n;return a.jsx(D.Tooltip2,{content:t,children:a.jsx(H.Button,{...s,"aria-label":r??t,icon:e,shape:"rectangle",size:"small",type:"button",variant:"ghost"})})}function G(n){const{actions:r}=n;function e(t){t.stopPropagation()}return a.jsx("td",{className:"nk-table__cell nk-table__action-cell","data-align":"right",onClick:e,children:r.length>0?a.jsx("span",{className:"nk-table__action-list",children:r.map(t=>o.createElement($,{...t,key:t.label}))}):null})}const J=o.forwardRef(function(r,e){const{children:t,className:s,...i}=r;return a.jsx(w,{...i,ref:e,align:"right",className:["nk-table__action-header-cell",s].filter(Boolean).join(" "),children:t??a.jsx("span",{className:"nk-table__visually-hidden",children:"Row actions"})})}),Q=o.forwardRef(function(r,e){const{"aria-label":t,actions:s,children:i,className:c,download:b,href:d,hrefLang:h,onClick:p,onNavigate:l,rel:u,target:k,...f}=r,g=o.useRef(null),C=o.useContext(v),T=d!==void 0||p!==void 0,j=(t==null?void 0:t.trim())||(d!==void 0?"Open row":"Activate row");function y(m){g.current=m}let x;d!==void 0?x={ariaLabel:j,kind:"link",linkProperties:{download:b,href:d,hrefLang:h,onNavigate:l,rel:u,target:k},reference:y}:p!==void 0&&(x={ariaLabel:j,kind:"button",onClick:p,reference:y});const E=x?X(i,x):{content:i};function B(m){if(m.defaultPrevented)return;const N=m.target;if(!(N instanceof Element)||Y(N,m.currentTarget))return;const _=g.current;if(!_)return;const R=_.ownerDocument.defaultView;if(!R){_.click();return}_.dispatchEvent(new R.MouseEvent("click",{altKey:m.altKey,bubbles:!0,button:m.button,buttons:m.buttons,cancelable:!0,clientX:m.clientX,clientY:m.clientY,ctrlKey:m.ctrlKey,metaKey:m.metaKey,shiftKey:m.shiftKey}))}const L=C==="head"?a.jsx(J,{}):a.jsx(G,{actions:s??[]});return a.jsxs("tr",{...f,ref:e,"aria-label":T?void 0:t,className:["nk-table__row",c].filter(Boolean).join(" "),"data-interactive":T||void 0,onClick:T?B:void 0,children:[E.content,L]})});function U(){const n=o.useRef(null),r=o.useRef(null),[e,t]=o.useState(!1),[s,i]=o.useState(!1);o.useEffect(()=>{const b=n.current,d=r.current;if(!b||!d)return;const h=b,p=d;function l(){const g=h.scrollWidth>h.clientWidth;t(g),g||i(!1)}l();const u=h.ownerDocument.defaultView;u==null||u.addEventListener("resize",l);const k=u==null?void 0:u.ResizeObserver,f=k?new k(l):void 0;return f==null||f.observe(h),f==null||f.observe(p),()=>{u==null||u.removeEventListener("resize",l),f==null||f.disconnect()}},[]);function c(b){i(e&&b.currentTarget.scrollLeft>1)}return{containerReference:n,contentReference:r,isScrollable:e,isScrolled:s,handleScroll:c}}const W=o.forwardRef(function(r,e){const{"aria-label":t,children:s,className:i,containerClassName:c,frame:b="outline",...d}=r,{containerReference:h,contentReference:p,isScrollable:l,isScrolled:u,handleScroll:k}=U(),f=t?`${t} scroll area`:"Scrollable table",g=o.useCallback(C=>{p.current=C,A.assignElementReference(e,C)},[p,e]);return a.jsx(I.Surface,{ref:h,"aria-label":l?f:void 0,className:["nk-table",c].filter(Boolean).join(" "),"data-frame":b,"data-scrolled":u||void 0,onScroll:k,role:l?"region":void 0,tabIndex:l?0:void 0,children:a.jsx("table",{...d,ref:g,"aria-label":t,className:["nk-table__element",i].filter(Boolean).join(" "),children:s})})}),Z=Object.assign(W,{Body:K,Cell:P,Foot:q,HeaderCell:w,Head:z,Row:Q});exports.Table=Z;