zaravand-ui 7.0.2 → 7.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Input/Input.formatting.cjs +1 -1
- package/dist/components/Input/Input.formatting.js +35 -17
- package/dist/components/Input/Input.interface.d.cts +5 -1
- package/dist/components/Input/Input.interface.d.ts +5 -1
- package/dist/components/OtpInput/OtpInput.cjs +1 -0
- package/dist/components/OtpInput/OtpInput.d.cts +10 -0
- package/dist/components/OtpInput/OtpInput.d.ts +10 -0
- package/dist/components/OtpInput/OtpInput.interface.d.cts +49 -0
- package/dist/components/OtpInput/OtpInput.interface.d.ts +49 -0
- package/dist/components/OtpInput/OtpInput.js +150 -0
- package/dist/components/OtpInput/OtpInput.variant.cjs +1 -0
- package/dist/components/OtpInput/OtpInput.variant.d.cts +6 -0
- package/dist/components/OtpInput/OtpInput.variant.d.ts +6 -0
- package/dist/components/OtpInput/OtpInput.variant.js +15 -0
- package/dist/components/Table/Table.cjs +1 -1
- package/dist/components/Table/Table.interface.d.cts +42 -1
- package/dist/components/Table/Table.interface.d.ts +42 -1
- package/dist/components/Table/Table.js +414 -373
- package/dist/components/Table/Table.utils.cjs +1 -1
- package/dist/components/Table/Table.utils.d.cts +2 -0
- package/dist/components/Table/Table.utils.d.ts +2 -0
- package/dist/components/Table/Table.utils.js +20 -16
- package/dist/components/Table/TableActionsContext.cjs +1 -0
- package/dist/components/Table/TableActionsContext.d.cts +26 -0
- package/dist/components/Table/TableActionsContext.d.ts +26 -0
- package/dist/components/Table/TableActionsContext.js +5 -0
- package/dist/components/Table/TableActiveFilters.d.cts +1 -1
- package/dist/components/Table/TableActiveFilters.d.ts +1 -1
- package/dist/components/Table/TableColumnFilter.cjs +1 -1
- package/dist/components/Table/TableColumnFilter.d.cts +3 -0
- package/dist/components/Table/TableColumnFilter.d.ts +3 -0
- package/dist/components/Table/TableColumnFilter.js +58 -28
- package/dist/components/Table/TableFilterRegistry.cjs +1 -0
- package/dist/components/Table/TableFilterRegistry.d.cts +13 -0
- package/dist/components/Table/TableFilterRegistry.d.ts +13 -0
- package/dist/components/Table/TableFilterRegistry.js +5 -0
- package/dist/components/Table/TableParts.cjs +1 -1
- package/dist/components/Table/TableParts.js +56 -34
- package/dist/components/Table/TableRowActions.cjs +1 -0
- package/dist/components/Table/TableRowActions.d.cts +14 -0
- package/dist/components/Table/TableRowActions.d.ts +14 -0
- package/dist/components/Table/TableRowActions.js +110 -0
- package/dist/components/VerticalTabs/VerticalTabs.cjs +1 -0
- package/dist/components/VerticalTabs/VerticalTabs.d.cts +4 -0
- package/dist/components/VerticalTabs/VerticalTabs.d.ts +4 -0
- package/dist/components/VerticalTabs/VerticalTabs.interface.d.cts +41 -0
- package/dist/components/VerticalTabs/VerticalTabs.interface.d.ts +41 -0
- package/dist/components/VerticalTabs/VerticalTabs.js +196 -0
- package/dist/components/VerticalTabs/VerticalTabs.variant.cjs +1 -0
- package/dist/components/VerticalTabs/VerticalTabs.variant.d.cts +19 -0
- package/dist/components/VerticalTabs/VerticalTabs.variant.d.ts +19 -0
- package/dist/components/VerticalTabs/VerticalTabs.variant.js +48 -0
- package/dist/components/shared/responsiveScale.cjs +1 -1
- package/dist/components/shared/responsiveScale.d.cts +3 -1
- package/dist/components/shared/responsiveScale.d.ts +3 -1
- package/dist/components/shared/responsiveScale.js +2 -2
- package/dist/config/messages.cjs +1 -1
- package/dist/config/messages.d.cts +4 -0
- package/dist/config/messages.d.ts +4 -0
- package/dist/config/messages.js +2 -0
- package/dist/index.cjs +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.cts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +20 -16
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../../services/convertToEnglishDigits/convertToEnglishDigits.cjs`),t=require(`../../services/localizeDigits/localizeDigits.cjs`);var n=96,r=56,i=16,a=/^(\d*\.?\d+)\s*(px|%|rem|em)?$/i;function o(){if(typeof window>`u`||typeof document>`u`)return i;let e=Number.parseFloat(window.getComputedStyle(document.documentElement).fontSize);return Number.isFinite(e)&&e>0?e:i}function s(e){if(typeof e==`number`)return Number.isFinite(e)&&e>0?{kind:`weight`,value:e}:{kind:`weight`,value:n};let t=typeof e==`string`?e.trim().match(a):null,r=t?Number.parseFloat(t[1]):NaN;if(!t||!Number.isFinite(r)||r<=0)return{kind:`weight`,value:n};let i=(t[2]??`px`).toLowerCase();return i===`%`?{kind:`percent`,value:r}:i===`rem`||i===`em`?{kind:`weight`,value:r*o()}:{kind:`weight`,value:r}}function c(e,t,n){let i=n?{width:`112px`,minWidth:`112px`}:void 0;if(e.length===0&&!t)return{rowNumberColumnStyle:void 0,columnStyleByKey:{},actionsColumnStyle:i};let a=t?r:0,o=e.map(e=>s(e.width)),c=o.reduce((e,t)=>t.kind===`percent`?e+t.value:e,0),l=c>100?100/c:1,u=Math.max(0,100-c*l),d=a+o.reduce((e,t)=>t.kind===`weight`?e+t.value:e,0),f=e=>d>0?e/d*u:0,p=e=>({width:`${e.toFixed(4)}%`}),m=Object.fromEntries(e.map((e,t)=>{let n=o[t],r=n.kind===`percent`?n.value*l:f(n.value);return[e.key,p(r)]}));return{rowNumberColumnStyle:t?p(f(a)):void 0,columnStyleByKey:m,actionsColumnStyle:i}}function l(e,t){return typeof e==`number`&&Number.isFinite(e)&&e>0?Math.min(12,Math.max(1,Math.floor(e))):t>0?Math.min(12,t):6}function u(e,t){let n=t%3;return e.type===`checkbox`?`zui:size-4`:e.type===`number`||e.type===`money`?n===0?`zui:h-4 zui:w-16`:n===1?`zui:h-4 zui:w-12`:`zui:h-4 zui:w-20`:e.type===`date`?n===0?`zui:h-4 zui:w-28`:n===1?`zui:h-4 zui:w-24`:`zui:h-4 zui:w-32`:e.type===`textarea`?n===0?`zui:h-4 zui:w-[92%]`:n===1?`zui:h-4 zui:w-[76%]`:`zui:h-4 zui:w-[84%]`:n===0?`zui:h-4 zui:w-[78%]`:n===1?`zui:h-4 zui:w-[62%]`:`zui:h-4 zui:w-[86%]`}function d(e){return e==null?!0:typeof e==`string`?e.trim().length===0:!1}function f(e){if(typeof e==`number`)return Number.isFinite(e)?e:null;if(typeof e==`string`){let t=e.replace(/,/g,``).trim();if(t.length===0)return null;let n=Number(t);return Number.isFinite(n)?n:null}return null}function p(e){return e.toLocaleString(`en-US`)}function m(e){if(e instanceof Date&&!Number.isNaN(e.getTime()))return e;if(typeof e==`string`&&e.trim().length>0){let t=new Date(e);if(!Number.isNaN(t.getTime()))return t}return null}function h(e){return typeof e.placeholder==`string`&&e.placeholder.trim().length>0?e.placeholder:`---`}function g(e){return typeof e.displayPlaceholder==`string`&&e.displayPlaceholder.trim().length>0?e.displayPlaceholder:h(e)}function _(e,t){if(t.type!==`select`&&t.type!==`radio`||!Array.isArray(t.options)||t.options.length===0)return null;let n=String(e).trim();if(n.length===0)return null;let r=t.options.find(e=>e.value.trim()===n);if(r){let e=r.label.trim();return e.length>0?e:null}let i=e=>{let t=e.trim().toLocaleLowerCase();return/^[0-9a-f-]+$/i.test(t)?t.replaceAll(`-`,``):t},a=n.toLocaleLowerCase(),o=t.options.find(e=>e.value.trim().toLocaleLowerCase()===a);if(o){let e=o.label.trim();return e.length>0?e:null}let s=i(n),c=t.options.find(e=>i(e.value)===s);if(!c)return null;let l=c.label.trim();return l.length>0?l:null}var v=new Map;function y(e){let t=v.get(e);return t||(t=new Intl.DateTimeFormat(`${e}-u-ca-persian`,{dateStyle:`medium`}),v.set(e,t)),t}function b(t,n,{messages:r}){if(d(t))return g(n);if(n.type===`checkbox`)return t===!0?r.common.yes:r.common.no;if(n.type===`date`){let i=m(t);return i?e.convertToEnglishDigits({value:y(r.calendar.locale).format(i)}):g(n)}if(n.type===`money`){let e=f(t);return e===null?g(n):p(e)}return typeof t==`string`||typeof t==`number`?_(t,n)||(n.type===`select`&&n.optionsSource?g(n):String(t)):g(n)}function x(e,n,r){return t.localizeDigits(b(e,n,r),r.digits)}function S(e,t,n){if(typeof n!=`function`)return;let r=n(e,t);if(typeof r==`number`)return Number.isFinite(r)?r:void 0;if(typeof r==`string`){let e=r.trim();return e.length>0?e:void 0}}function
|
|
1
|
+
const e=require(`../../services/convertToEnglishDigits/convertToEnglishDigits.cjs`),t=require(`../../services/localizeDigits/localizeDigits.cjs`);var n=96,r=56,i=16,a=/^(\d*\.?\d+)\s*(px|%|rem|em)?$/i;function o(){if(typeof window>`u`||typeof document>`u`)return i;let e=Number.parseFloat(window.getComputedStyle(document.documentElement).fontSize);return Number.isFinite(e)&&e>0?e:i}function s(e){if(typeof e==`number`)return Number.isFinite(e)&&e>0?{kind:`weight`,value:e}:{kind:`weight`,value:n};let t=typeof e==`string`?e.trim().match(a):null,r=t?Number.parseFloat(t[1]):NaN;if(!t||!Number.isFinite(r)||r<=0)return{kind:`weight`,value:n};let i=(t[2]??`px`).toLowerCase();return i===`%`?{kind:`percent`,value:r}:i===`rem`||i===`em`?{kind:`weight`,value:r*o()}:{kind:`weight`,value:r}}function c(e,t,n){let i=n?{width:`112px`,minWidth:`112px`}:void 0;if(e.length===0&&!t)return{rowNumberColumnStyle:void 0,columnStyleByKey:{},actionsColumnStyle:i};let a=t?r:0,o=e.map(e=>s(e.width)),c=o.reduce((e,t)=>t.kind===`percent`?e+t.value:e,0),l=c>100?100/c:1,u=Math.max(0,100-c*l),d=a+o.reduce((e,t)=>t.kind===`weight`?e+t.value:e,0),f=e=>d>0?e/d*u:0,p=e=>({width:`${e.toFixed(4)}%`}),m=Object.fromEntries(e.map((e,t)=>{let n=o[t],r=n.kind===`percent`?n.value*l:f(n.value);return[e.key,p(r)]}));return{rowNumberColumnStyle:t?p(f(a)):void 0,columnStyleByKey:m,actionsColumnStyle:i}}function l(e,t){return typeof e==`number`&&Number.isFinite(e)&&e>0?Math.min(12,Math.max(1,Math.floor(e))):t>0?Math.min(12,t):6}function u(e,t){let n=t%3;return e.type===`checkbox`?`zui:size-4`:e.type===`number`||e.type===`money`?n===0?`zui:h-4 zui:w-16`:n===1?`zui:h-4 zui:w-12`:`zui:h-4 zui:w-20`:e.type===`date`?n===0?`zui:h-4 zui:w-28`:n===1?`zui:h-4 zui:w-24`:`zui:h-4 zui:w-32`:e.type===`textarea`?n===0?`zui:h-4 zui:w-[92%]`:n===1?`zui:h-4 zui:w-[76%]`:`zui:h-4 zui:w-[84%]`:n===0?`zui:h-4 zui:w-[78%]`:n===1?`zui:h-4 zui:w-[62%]`:`zui:h-4 zui:w-[86%]`}function d(e){return e==null?!0:typeof e==`string`?e.trim().length===0:!1}function f(e){if(typeof e==`number`)return Number.isFinite(e)?e:null;if(typeof e==`string`){let t=e.replace(/,/g,``).trim();if(t.length===0)return null;let n=Number(t);return Number.isFinite(n)?n:null}return null}function p(e){return e.toLocaleString(`en-US`)}function m(e){if(e instanceof Date&&!Number.isNaN(e.getTime()))return e;if(typeof e==`string`&&e.trim().length>0){let t=new Date(e);if(!Number.isNaN(t.getTime()))return t}return null}function h(e){return typeof e.placeholder==`string`&&e.placeholder.trim().length>0?e.placeholder:`---`}function g(e){return typeof e.displayPlaceholder==`string`&&e.displayPlaceholder.trim().length>0?e.displayPlaceholder:h(e)}function _(e,t){if(t.type!==`select`&&t.type!==`radio`||!Array.isArray(t.options)||t.options.length===0)return null;let n=String(e).trim();if(n.length===0)return null;let r=t.options.find(e=>e.value.trim()===n);if(r){let e=r.label.trim();return e.length>0?e:null}let i=e=>{let t=e.trim().toLocaleLowerCase();return/^[0-9a-f-]+$/i.test(t)?t.replaceAll(`-`,``):t},a=n.toLocaleLowerCase(),o=t.options.find(e=>e.value.trim().toLocaleLowerCase()===a);if(o){let e=o.label.trim();return e.length>0?e:null}let s=i(n),c=t.options.find(e=>i(e.value)===s);if(!c)return null;let l=c.label.trim();return l.length>0?l:null}var v=new Map;function y(e){let t=v.get(e);return t||(t=new Intl.DateTimeFormat(`${e}-u-ca-persian`,{dateStyle:`medium`}),v.set(e,t)),t}function b(t,n,{messages:r}){if(d(t))return g(n);if(n.type===`checkbox`)return t===!0?r.common.yes:r.common.no;if(n.type===`date`){let i=m(t);return i?e.convertToEnglishDigits({value:y(r.calendar.locale).format(i)}):g(n)}if(n.type===`money`){let e=f(t);return e===null?g(n):p(e)}return typeof t==`string`||typeof t==`number`?_(t,n)||(n.type===`select`&&n.optionsSource?g(n):String(t)):g(n)}function x(e,n,r){return t.localizeDigits(b(e,n,r),r.digits)}function S(e){let t=e.target.closest(`button, a, input, textarea, select, label, [role="button"], [role="combobox"], [role="checkbox"]`);return t!==null&&e.currentTarget.contains(t)}function C(e,t,n){if(typeof n!=`function`)return;let r=n(e,t);if(typeof r==`number`)return Number.isFinite(r)?r:void 0;if(typeof r==`string`){let e=r.trim();return e.length>0?e:void 0}}function w(e,t,n,r){if(n!==void 0&&typeof r==`function`){let t=e.findIndex((e,t)=>C(e,t,r)===n);if(t>=0)return t}return t>=0&&t<e.length?t:-1}function T(e,t){if(d(e))return t.type===`number`||t.type===`money`||t.type===`date`?-1/0:``;if(t.type===`number`||t.type===`money`)return f(e)??-1/0;if(t.type===`date`){let t=m(e);return t?t.getTime():-1/0}return typeof e==`number`?e:String(e)}function E(e,t,n,r){let i=T(e[n.key],n),a=T(t[n.key],n),o=typeof i==`number`&&typeof a==`number`?i-a:String(i).localeCompare(String(a),`fa`);return r===`asc`?o:-o}function D(e,t){return e?.sortKey===t?e.direction===`asc`?{sortKey:t,direction:`desc`}:null:{sortKey:t,direction:`asc`}}function O(e){return e===`asc`?`ascending`:e===`desc`?`descending`:`none`}function k(e,t,n){return t===`asc`?`${n.sortBy} ${e} (${n.sortDescending})`:t===`desc`?`${n.sortClear} ${e} (${n.sortDefault})`:`${n.sortBy} ${e} (${n.sortAscending})`}function A(e,t,n,r,i){let a=w(e,t,n,r);if(a<0)return e;let o=[...e];return o[a]=i,o}function j(e){return e===void 0||e.length===0}function M(e,t){return e.map(e=>t.find(t=>t.value===e)?.label??e).join(`, `)}function N(e,t,n){let r=e[t.key];return n.includes(r==null?``:String(r).trim())}function P(e,t,n){if(Array.isArray(e.options)&&e.options.length>0)return e.options;if(e.optionsSource)return[];let r=new Map;return t.forEach(t=>{let i=t[e.key],a=i==null?``:String(i).trim();a.length>0&&!r.has(a)&&r.set(a,x(i,e,n))}),Array.from(r,([e,t])=>({value:e,label:t})).sort((e,t)=>e.label.localeCompare(t.label,void 0,{numeric:!0}))}exports.compareTableRowsByColumn=E,exports.formatCellValue=x,exports.isEmptyFilterValue=j,exports.isInsideInteractiveControl=S,exports.replaceRowByIdentifier=A,exports.resolveAriaSort=O,exports.resolveColumnWidthPercentages=c,exports.resolveFilterOptions=P,exports.resolveFilterText=M,exports.resolveLoadingCellSkeletonClassName=u,exports.resolveLoadingRowsCount=l,exports.resolveNextSort=D,exports.resolvePlaceholder=h,exports.resolveSafeRowId=C,exports.resolveSortToggleTooltipText=k,exports.rowMatchesColumnFilter=N;
|
|
@@ -21,6 +21,8 @@ export type TableCellFormatOptions = {
|
|
|
21
21
|
messages: ZuiMessages;
|
|
22
22
|
};
|
|
23
23
|
export declare function formatCellValue(value: unknown, column: TableSchemaColumn, options: TableCellFormatOptions): string;
|
|
24
|
+
/** True when a click landed on a control inside the row (a Select cell, a link...), not on the card. */
|
|
25
|
+
export declare function isInsideInteractiveControl(event: React.MouseEvent<HTMLElement>): boolean;
|
|
24
26
|
export declare function resolveSafeRowId(row: DynamicTableRow, index: number, getRowId?: TableRowIdResolver): TableRowId | undefined;
|
|
25
27
|
export declare function findRowIndexByIdentifier(rows: DynamicTableRow[], targetRowIndex: number, targetRowId: TableRowId | undefined, getRowId?: TableRowIdResolver): number;
|
|
26
28
|
export declare function compareTableRowsByColumn(rowA: DynamicTableRow, rowB: DynamicTableRow, column: TableSchemaColumn, direction: TableSortDirection): number;
|
|
@@ -21,6 +21,8 @@ export type TableCellFormatOptions = {
|
|
|
21
21
|
messages: ZuiMessages;
|
|
22
22
|
};
|
|
23
23
|
export declare function formatCellValue(value: unknown, column: TableSchemaColumn, options: TableCellFormatOptions): string;
|
|
24
|
+
/** True when a click landed on a control inside the row (a Select cell, a link...), not on the card. */
|
|
25
|
+
export declare function isInsideInteractiveControl(event: React.MouseEvent<HTMLElement>): boolean;
|
|
24
26
|
export declare function resolveSafeRowId(row: DynamicTableRow, index: number, getRowId?: TableRowIdResolver): TableRowId | undefined;
|
|
25
27
|
export declare function findRowIndexByIdentifier(rows: DynamicTableRow[], targetRowIndex: number, targetRowId: TableRowId | undefined, getRowId?: TableRowIdResolver): number;
|
|
26
28
|
export declare function compareTableRowsByColumn(rowA: DynamicTableRow, rowB: DynamicTableRow, column: TableSchemaColumn, direction: TableSortDirection): number;
|
|
@@ -132,7 +132,11 @@ function b(t, n, { messages: r }) {
|
|
|
132
132
|
function x(e, n, r) {
|
|
133
133
|
return t(b(e, n, r), r.digits);
|
|
134
134
|
}
|
|
135
|
-
function S(e
|
|
135
|
+
function S(e) {
|
|
136
|
+
let t = e.target.closest("button, a, input, textarea, select, label, [role=\"button\"], [role=\"combobox\"], [role=\"checkbox\"]");
|
|
137
|
+
return t !== null && e.currentTarget.contains(t);
|
|
138
|
+
}
|
|
139
|
+
function C(e, t, n) {
|
|
136
140
|
if (typeof n != "function") return;
|
|
137
141
|
let r = n(e, t);
|
|
138
142
|
if (typeof r == "number") return Number.isFinite(r) ? r : void 0;
|
|
@@ -141,14 +145,14 @@ function S(e, t, n) {
|
|
|
141
145
|
return e.length > 0 ? e : void 0;
|
|
142
146
|
}
|
|
143
147
|
}
|
|
144
|
-
function
|
|
148
|
+
function w(e, t, n, r) {
|
|
145
149
|
if (n !== void 0 && typeof r == "function") {
|
|
146
|
-
let t = e.findIndex((e, t) =>
|
|
150
|
+
let t = e.findIndex((e, t) => C(e, t, r) === n);
|
|
147
151
|
if (t >= 0) return t;
|
|
148
152
|
}
|
|
149
153
|
return t >= 0 && t < e.length ? t : -1;
|
|
150
154
|
}
|
|
151
|
-
function
|
|
155
|
+
function T(e, t) {
|
|
152
156
|
if (d(e)) return t.type === "number" || t.type === "money" || t.type === "date" ? -Infinity : "";
|
|
153
157
|
if (t.type === "number" || t.type === "money") return f(e) ?? -Infinity;
|
|
154
158
|
if (t.type === "date") {
|
|
@@ -157,11 +161,11 @@ function w(e, t) {
|
|
|
157
161
|
}
|
|
158
162
|
return typeof e == "number" ? e : String(e);
|
|
159
163
|
}
|
|
160
|
-
function
|
|
161
|
-
let i =
|
|
164
|
+
function E(e, t, n, r) {
|
|
165
|
+
let i = T(e[n.key], n), a = T(t[n.key], n), o = typeof i == "number" && typeof a == "number" ? i - a : String(i).localeCompare(String(a), "fa");
|
|
162
166
|
return r === "asc" ? o : -o;
|
|
163
167
|
}
|
|
164
|
-
function
|
|
168
|
+
function D(e, t) {
|
|
165
169
|
return e?.sortKey === t ? e.direction === "asc" ? {
|
|
166
170
|
sortKey: t,
|
|
167
171
|
direction: "desc"
|
|
@@ -170,29 +174,29 @@ function E(e, t) {
|
|
|
170
174
|
direction: "asc"
|
|
171
175
|
};
|
|
172
176
|
}
|
|
173
|
-
function
|
|
177
|
+
function O(e) {
|
|
174
178
|
return e === "asc" ? "ascending" : e === "desc" ? "descending" : "none";
|
|
175
179
|
}
|
|
176
|
-
function
|
|
180
|
+
function k(e, t, n) {
|
|
177
181
|
return t === "asc" ? `${n.sortBy} ${e} (${n.sortDescending})` : t === "desc" ? `${n.sortClear} ${e} (${n.sortDefault})` : `${n.sortBy} ${e} (${n.sortAscending})`;
|
|
178
182
|
}
|
|
179
|
-
function
|
|
180
|
-
let a =
|
|
183
|
+
function A(e, t, n, r, i) {
|
|
184
|
+
let a = w(e, t, n, r);
|
|
181
185
|
if (a < 0) return e;
|
|
182
186
|
let o = [...e];
|
|
183
187
|
return o[a] = i, o;
|
|
184
188
|
}
|
|
185
|
-
function
|
|
189
|
+
function j(e) {
|
|
186
190
|
return e === void 0 || e.length === 0;
|
|
187
191
|
}
|
|
188
|
-
function
|
|
192
|
+
function M(e, t) {
|
|
189
193
|
return e.map((e) => t.find((t) => t.value === e)?.label ?? e).join(", ");
|
|
190
194
|
}
|
|
191
|
-
function
|
|
195
|
+
function N(e, t, n) {
|
|
192
196
|
let r = e[t.key];
|
|
193
197
|
return n.includes(r == null ? "" : String(r).trim());
|
|
194
198
|
}
|
|
195
|
-
function
|
|
199
|
+
function P(e, t, n) {
|
|
196
200
|
if (Array.isArray(e.options) && e.options.length > 0) return e.options;
|
|
197
201
|
if (e.optionsSource) return [];
|
|
198
202
|
let r = /* @__PURE__ */ new Map();
|
|
@@ -205,4 +209,4 @@ function N(e, t, n) {
|
|
|
205
209
|
})).sort((e, t) => e.label.localeCompare(t.label, void 0, { numeric: !0 }));
|
|
206
210
|
}
|
|
207
211
|
//#endregion
|
|
208
|
-
export {
|
|
212
|
+
export { E as compareTableRowsByColumn, x as formatCellValue, j as isEmptyFilterValue, S as isInsideInteractiveControl, A as replaceRowByIdentifier, O as resolveAriaSort, c as resolveColumnWidthPercentages, P as resolveFilterOptions, M as resolveFilterText, u as resolveLoadingCellSkeletonClassName, l as resolveLoadingRowsCount, D as resolveNextSort, h as resolvePlaceholder, C as resolveSafeRowId, k as resolveSortToggleTooltipText, N as rowMatchesColumnFilter };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`../../_virtual/_rolldown/runtime.cjs`);let t=require(`react`);t=e.__toESM(t,1);var n=t.createContext(null),r=t.createContext(null);exports.TableActionsContext=n,exports.TableRowActionsRegistryContext=r;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { ActionSheetAction } from "../shared/ActionSheet.cjs";
|
|
3
|
+
/**
|
|
4
|
+
* What a `Table` shares with the row actions placed inside its hand-written rows
|
|
5
|
+
* (`TableRowActions`, `TableActionsHead`), so they behave like the actions of a schema table: one
|
|
6
|
+
* action at a time, nothing clickable while the table is mutating, and on phones the card opens
|
|
7
|
+
* the actions as a sheet.
|
|
8
|
+
*/
|
|
9
|
+
export type TableActionsContextValue = {
|
|
10
|
+
isMobile: boolean;
|
|
11
|
+
/** True while a mutation is running or another action is still pending. */
|
|
12
|
+
isBusy: boolean;
|
|
13
|
+
/** Runs an action under the table's exclusive lock (a no-op while the table is mutating). */
|
|
14
|
+
run: (action: () => unknown) => Promise<void>;
|
|
15
|
+
/** Opens the phone sheet of a row's actions. */
|
|
16
|
+
openRowSheet: (actions: ActionSheetAction[]) => void;
|
|
17
|
+
};
|
|
18
|
+
export declare const TableActionsContext: React.Context<TableActionsContextValue | null>;
|
|
19
|
+
/** Reads the actions of a row lazily, at the moment the card is tapped. */
|
|
20
|
+
export type TableRowActionsGetter = () => ActionSheetAction[];
|
|
21
|
+
export type TableRowActionsRegistry = {
|
|
22
|
+
/** `TableRowActions` hands its row the actions to open on a tap; `null` withdraws them. */
|
|
23
|
+
register: (getter: TableRowActionsGetter | null) => void;
|
|
24
|
+
};
|
|
25
|
+
/** Provided by each `TableRow`, so a `TableRowActions` inside it can reach its row. */
|
|
26
|
+
export declare const TableRowActionsRegistryContext: React.Context<TableRowActionsRegistry | null>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { ActionSheetAction } from "../shared/ActionSheet.js";
|
|
3
|
+
/**
|
|
4
|
+
* What a `Table` shares with the row actions placed inside its hand-written rows
|
|
5
|
+
* (`TableRowActions`, `TableActionsHead`), so they behave like the actions of a schema table: one
|
|
6
|
+
* action at a time, nothing clickable while the table is mutating, and on phones the card opens
|
|
7
|
+
* the actions as a sheet.
|
|
8
|
+
*/
|
|
9
|
+
export type TableActionsContextValue = {
|
|
10
|
+
isMobile: boolean;
|
|
11
|
+
/** True while a mutation is running or another action is still pending. */
|
|
12
|
+
isBusy: boolean;
|
|
13
|
+
/** Runs an action under the table's exclusive lock (a no-op while the table is mutating). */
|
|
14
|
+
run: (action: () => unknown) => Promise<void>;
|
|
15
|
+
/** Opens the phone sheet of a row's actions. */
|
|
16
|
+
openRowSheet: (actions: ActionSheetAction[]) => void;
|
|
17
|
+
};
|
|
18
|
+
export declare const TableActionsContext: React.Context<TableActionsContextValue | null>;
|
|
19
|
+
/** Reads the actions of a row lazily, at the moment the card is tapped. */
|
|
20
|
+
export type TableRowActionsGetter = () => ActionSheetAction[];
|
|
21
|
+
export type TableRowActionsRegistry = {
|
|
22
|
+
/** `TableRowActions` hands its row the actions to open on a tap; `null` withdraws them. */
|
|
23
|
+
register: (getter: TableRowActionsGetter | null) => void;
|
|
24
|
+
};
|
|
25
|
+
/** Provided by each `TableRow`, so a `TableRowActions` inside it can reach its row. */
|
|
26
|
+
export declare const TableRowActionsRegistryContext: React.Context<TableRowActionsRegistry | null>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { TableFilterValues, TableSchemaColumn, TableSelectOption } from "./Table.interface.cjs";
|
|
2
2
|
type TableActiveFiltersProps = {
|
|
3
|
-
columns: TableSchemaColumn[];
|
|
3
|
+
columns: Pick<TableSchemaColumn, "key" | "label">[];
|
|
4
4
|
values: TableFilterValues;
|
|
5
5
|
optionsByColumn: Record<string, TableSelectOption[]>;
|
|
6
6
|
onRemove: (columnKey: string) => void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { TableFilterValues, TableSchemaColumn, TableSelectOption } from "./Table.interface.js";
|
|
2
2
|
type TableActiveFiltersProps = {
|
|
3
|
-
columns: TableSchemaColumn[];
|
|
3
|
+
columns: Pick<TableSchemaColumn, "key" | "label">[];
|
|
4
4
|
values: TableFilterValues;
|
|
5
5
|
optionsByColumn: Record<string, TableSelectOption[]>;
|
|
6
6
|
onRemove: (columnKey: string) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";require(`../../_virtual/_rolldown/runtime.cjs`)
|
|
1
|
+
"use client";const e=require(`../../_virtual/_rolldown/runtime.cjs`),t=require(`../../config/useZuiConfig.cjs`),n=require(`../../services/localizeDigits/localizeDigits.cjs`),r=require(`../Select/Select.cjs`),i=require(`./Table.constants.cjs`),a=require(`./Table.utils.cjs`),o=require(`./Table.variant.cjs`),s=require(`./TableFilterRegistry.cjs`);let c=require(`react`);c=e.__toESM(c,1);let l=require(`react/jsx-runtime`),u=require(`lucide-react`);function d({column:e,value:d,onChange:f,options:p}){let{messages:m,digits:h}=t.useZuiConfig(),g=!a.isEmptyFilterValue(d),_=`${m.table.filterBy} ${n.localizeDigits(e.label,h)}`,v=c.useContext(s.TableFilterRegistryContext),y=c.useRef({column:e,value:d,options:p,onChange:f}),b=JSON.stringify(d??[]),x=JSON.stringify(p.map(({value:e,label:t})=>[e,t]));return c.useEffect(()=>{y.current={column:e,value:d,options:p,onChange:f}}),c.useEffect(()=>{v?.register({column:{key:e.key,label:e.label},value:y.current.value,options:y.current.options,onChange:e=>y.current.onChange(e)})},[v,e.key,e.label,b,x]),c.useEffect(()=>()=>v?.unregister(e.key),[v,e.key]),(0,l.jsx)(`span`,{"data-slot":`table-filter`,className:`zui:inline-flex zui:shrink-0`,children:(0,l.jsxs)(r.default,{type:`multi`,isSearch:!0,searchActions:!1,placeholder:_,options:p,remoteOptions:e.optionsSource,value:d??[],onValueChange:e=>f(e.length>0?e:void 0),children:[(0,l.jsxs)(r.SelectTrigger,{unstyled:!0,"aria-label":_,tooltip:_,"data-slot":`table-filter-toggle-button`,"data-active":g||void 0,className:o.tableFilterToggleVariants({active:g}),children:[(0,l.jsx)(u.Funnel,{className:i.filterIconClassName,fill:g?`currentColor`:`none`,"aria-hidden":`true`}),g?(0,l.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`table-filter-active-dot`,className:`zui:absolute zui:end-0 zui:top-0 zui:size-2 zui:rounded-full zui:bg-[var(--zui-color-surface)] zui:ring-2 zui:ring-[var(--zui-theme-action-primary)]`}):null]}),(0,l.jsx)(r.SelectContent,{className:`zui:w-60`})]})})}function f({column:e,value:i,onChange:a,options:o,open:s,onOpenChange:c}){let{messages:u,digits:d}=t.useZuiConfig();return(0,l.jsx)(`div`,{"data-slot":`table-filter-sheet`,"aria-hidden":`true`,className:`zui:sr-only`,children:(0,l.jsx)(r.default,{type:`multi`,isSearch:!0,searchActions:!1,placeholder:`${u.table.filterBy} ${n.localizeDigits(e.label,d)}`,options:o,remoteOptions:e.optionsSource,value:i??[],onValueChange:e=>a(e.length>0?e:void 0),open:s,onOpenChange:c,children:(0,l.jsx)(r.SelectTrigger,{unstyled:!0,tabIndex:-1})})})}exports.TableColumnFilterSheet=f,exports.default=d;
|
|
@@ -2,6 +2,9 @@ import type { TableColumnFilterProps } from "./Table.interface.cjs";
|
|
|
2
2
|
/**
|
|
3
3
|
* The filter button of a column header. It opens the same dropdown as `Select`: a multi-select of
|
|
4
4
|
* the values the column can have, with its search field.
|
|
5
|
+
*
|
|
6
|
+
* Inside a hand-written table the chips of the active filters are shown above the table by the
|
|
7
|
+
* table itself.
|
|
5
8
|
*/
|
|
6
9
|
export default function TableColumnFilter({ column, value, onChange, options, }: TableColumnFilterProps): import("react/jsx-runtime").JSX.Element;
|
|
7
10
|
type TableColumnFilterSheetProps = TableColumnFilterProps & {
|
|
@@ -2,6 +2,9 @@ import type { TableColumnFilterProps } from "./Table.interface.js";
|
|
|
2
2
|
/**
|
|
3
3
|
* The filter button of a column header. It opens the same dropdown as `Select`: a multi-select of
|
|
4
4
|
* the values the column can have, with its search field.
|
|
5
|
+
*
|
|
6
|
+
* Inside a hand-written table the chips of the active filters are shown above the table by the
|
|
7
|
+
* table itself.
|
|
5
8
|
*/
|
|
6
9
|
export default function TableColumnFilter({ column, value, onChange, options, }: TableColumnFilterProps): import("react/jsx-runtime").JSX.Element;
|
|
7
10
|
type TableColumnFilterSheetProps = TableColumnFilterProps & {
|
|
@@ -5,50 +5,80 @@ import n, { SelectContent as r, SelectTrigger as i } from "../Select/Select.js";
|
|
|
5
5
|
import { filterIconClassName as a } from "./Table.constants.js";
|
|
6
6
|
import { isEmptyFilterValue as o } from "./Table.utils.js";
|
|
7
7
|
import { tableFilterToggleVariants as s } from "./Table.variant.js";
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
8
|
+
import { TableFilterRegistryContext as c } from "./TableFilterRegistry.js";
|
|
9
|
+
import * as l from "react";
|
|
10
|
+
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
11
|
+
import { Funnel as f } from "lucide-react";
|
|
10
12
|
//#region src/components/Table/TableColumnFilter.tsx
|
|
11
|
-
function
|
|
12
|
-
let { messages:
|
|
13
|
-
|
|
13
|
+
function p({ column: p, value: m, onChange: h, options: g }) {
|
|
14
|
+
let { messages: _, digits: v } = e(), y = !o(m), b = `${_.table.filterBy} ${t(p.label, v)}`, x = l.useContext(c), S = l.useRef({
|
|
15
|
+
column: p,
|
|
16
|
+
value: m,
|
|
17
|
+
options: g,
|
|
18
|
+
onChange: h
|
|
19
|
+
}), C = JSON.stringify(m ?? []), w = JSON.stringify(g.map(({ value: e, label: t }) => [e, t]));
|
|
20
|
+
return l.useEffect(() => {
|
|
21
|
+
S.current = {
|
|
22
|
+
column: p,
|
|
23
|
+
value: m,
|
|
24
|
+
options: g,
|
|
25
|
+
onChange: h
|
|
26
|
+
};
|
|
27
|
+
}), l.useEffect(() => {
|
|
28
|
+
x?.register({
|
|
29
|
+
column: {
|
|
30
|
+
key: p.key,
|
|
31
|
+
label: p.label
|
|
32
|
+
},
|
|
33
|
+
value: S.current.value,
|
|
34
|
+
options: S.current.options,
|
|
35
|
+
onChange: (e) => S.current.onChange(e)
|
|
36
|
+
});
|
|
37
|
+
}, [
|
|
38
|
+
x,
|
|
39
|
+
p.key,
|
|
40
|
+
p.label,
|
|
41
|
+
C,
|
|
42
|
+
w
|
|
43
|
+
]), l.useEffect(() => () => x?.unregister(p.key), [x, p.key]), /* @__PURE__ */ u("span", {
|
|
14
44
|
"data-slot": "table-filter",
|
|
15
45
|
className: "zui:inline-flex zui:shrink-0",
|
|
16
|
-
children: /* @__PURE__ */
|
|
46
|
+
children: /* @__PURE__ */ d(n, {
|
|
17
47
|
type: "multi",
|
|
18
48
|
isSearch: !0,
|
|
19
49
|
searchActions: !1,
|
|
20
|
-
placeholder:
|
|
21
|
-
options:
|
|
22
|
-
remoteOptions:
|
|
23
|
-
value:
|
|
24
|
-
onValueChange: (e) =>
|
|
25
|
-
children: [/* @__PURE__ */
|
|
50
|
+
placeholder: b,
|
|
51
|
+
options: g,
|
|
52
|
+
remoteOptions: p.optionsSource,
|
|
53
|
+
value: m ?? [],
|
|
54
|
+
onValueChange: (e) => h(e.length > 0 ? e : void 0),
|
|
55
|
+
children: [/* @__PURE__ */ d(i, {
|
|
26
56
|
unstyled: !0,
|
|
27
|
-
"aria-label":
|
|
28
|
-
tooltip:
|
|
57
|
+
"aria-label": b,
|
|
58
|
+
tooltip: b,
|
|
29
59
|
"data-slot": "table-filter-toggle-button",
|
|
30
|
-
"data-active":
|
|
31
|
-
className: s({ active:
|
|
32
|
-
children: [/* @__PURE__ */
|
|
60
|
+
"data-active": y || void 0,
|
|
61
|
+
className: s({ active: y }),
|
|
62
|
+
children: [/* @__PURE__ */ u(f, {
|
|
33
63
|
className: a,
|
|
34
|
-
fill:
|
|
64
|
+
fill: y ? "currentColor" : "none",
|
|
35
65
|
"aria-hidden": "true"
|
|
36
|
-
}),
|
|
66
|
+
}), y ? /* @__PURE__ */ u("span", {
|
|
37
67
|
"aria-hidden": "true",
|
|
38
68
|
"data-slot": "table-filter-active-dot",
|
|
39
|
-
className: "zui:absolute zui:end-0 zui:top-0 zui:size-2 zui:rounded-full zui:bg-[var(--zui-color-surface)] zui:ring-2 zui:ring-[var(--zui-
|
|
69
|
+
className: "zui:absolute zui:end-0 zui:top-0 zui:size-2 zui:rounded-full zui:bg-[var(--zui-color-surface)] zui:ring-2 zui:ring-[var(--zui-theme-action-primary)]"
|
|
40
70
|
}) : null]
|
|
41
|
-
}), /* @__PURE__ */
|
|
71
|
+
}), /* @__PURE__ */ u(r, { className: "zui:w-60" })]
|
|
42
72
|
})
|
|
43
73
|
});
|
|
44
74
|
}
|
|
45
|
-
function
|
|
75
|
+
function m({ column: r, value: a, onChange: o, options: s, open: c, onOpenChange: l }) {
|
|
46
76
|
let { messages: d, digits: f } = e();
|
|
47
|
-
return /* @__PURE__ */
|
|
77
|
+
return /* @__PURE__ */ u("div", {
|
|
48
78
|
"data-slot": "table-filter-sheet",
|
|
49
79
|
"aria-hidden": "true",
|
|
50
80
|
className: "zui:sr-only",
|
|
51
|
-
children: /* @__PURE__ */
|
|
81
|
+
children: /* @__PURE__ */ u(n, {
|
|
52
82
|
type: "multi",
|
|
53
83
|
isSearch: !0,
|
|
54
84
|
searchActions: !1,
|
|
@@ -57,9 +87,9 @@ function f({ column: r, value: a, onChange: o, options: s, open: l, onOpenChange
|
|
|
57
87
|
remoteOptions: r.optionsSource,
|
|
58
88
|
value: a ?? [],
|
|
59
89
|
onValueChange: (e) => o(e.length > 0 ? e : void 0),
|
|
60
|
-
open:
|
|
61
|
-
onOpenChange:
|
|
62
|
-
children: /* @__PURE__ */
|
|
90
|
+
open: c,
|
|
91
|
+
onOpenChange: l,
|
|
92
|
+
children: /* @__PURE__ */ u(i, {
|
|
63
93
|
unstyled: !0,
|
|
64
94
|
tabIndex: -1
|
|
65
95
|
})
|
|
@@ -67,4 +97,4 @@ function f({ column: r, value: a, onChange: o, options: s, open: l, onOpenChange
|
|
|
67
97
|
});
|
|
68
98
|
}
|
|
69
99
|
//#endregion
|
|
70
|
-
export {
|
|
100
|
+
export { m as TableColumnFilterSheet, p as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`../../_virtual/_rolldown/runtime.cjs`);let t=require(`react`);t=e.__toESM(t,1);var n=t.createContext(null);exports.TableFilterRegistryContext=n;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { TableColumnFilterProps } from "./Table.interface.cjs";
|
|
3
|
+
/** A column filter placed in a hand-written table, as the `Table` that contains it keeps it. */
|
|
4
|
+
export type RegisteredTableFilter = TableColumnFilterProps;
|
|
5
|
+
export type TableFilterRegistry = {
|
|
6
|
+
register: (filter: RegisteredTableFilter) => void;
|
|
7
|
+
unregister: (columnKey: string) => void;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Lets a `TableColumnFilter` inside a hand-written table (`<Table>` with children) tell the table
|
|
11
|
+
* about its filter, so the table can list the active ones above itself like it does for a schema.
|
|
12
|
+
*/
|
|
13
|
+
export declare const TableFilterRegistryContext: React.Context<TableFilterRegistry | null>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { TableColumnFilterProps } from "./Table.interface.js";
|
|
3
|
+
/** A column filter placed in a hand-written table, as the `Table` that contains it keeps it. */
|
|
4
|
+
export type RegisteredTableFilter = TableColumnFilterProps;
|
|
5
|
+
export type TableFilterRegistry = {
|
|
6
|
+
register: (filter: RegisteredTableFilter) => void;
|
|
7
|
+
unregister: (columnKey: string) => void;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Lets a `TableColumnFilter` inside a hand-written table (`<Table>` with children) tell the table
|
|
11
|
+
* about its filter, so the table can list the active ones above itself like it does for a schema.
|
|
12
|
+
*/
|
|
13
|
+
export declare const TableFilterRegistryContext: React.Context<TableFilterRegistry | null>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";const e=require(`../../_virtual/_rolldown/runtime.cjs`),t=require(`../../lib/utils.cjs`),n=require(`./Table.variant.cjs`);let
|
|
1
|
+
"use client";const e=require(`../../_virtual/_rolldown/runtime.cjs`),t=require(`../../lib/utils.cjs`),n=require(`./TableActionsContext.cjs`),r=require(`./Table.utils.cjs`),i=require(`./Table.variant.cjs`);let a=require(`react`);a=e.__toESM(a,1);let o=require(`react/jsx-runtime`);var s=a.forwardRef(function({className:e,...n},r){return(0,o.jsx)(`thead`,{...n,ref:r,"data-slot":`table-header`,className:t.cn(i.tableHeaderVariants(),e)})}),c=a.forwardRef(function({className:e,...n},r){return(0,o.jsx)(`tbody`,{...n,ref:r,"data-slot":`table-body`,className:t.cn(i.tableBodyVariants(),e)})}),l=a.forwardRef(function({className:e,...n},r){return(0,o.jsx)(`tfoot`,{...n,ref:r,"data-slot":`table-footer`,className:t.cn(i.tableFooterVariants(),e)})}),u=a.forwardRef(function({className:e,state:s,slot:c=`table-row`,onClick:l,onKeyDown:u,...d},f){let p=a.useContext(n.TableActionsContext),m=a.useRef(null),[h,g]=a.useState(!1),_=a.useMemo(()=>({register:e=>{m.current=e,g(e!==null)}}),[]),v=h&&p?.isMobile===!0?{tabIndex:0,"aria-haspopup":`dialog`,"data-actionable":`true`,onClick:e=>{l?.(e),!e.defaultPrevented&&!r.isInsideInteractiveControl(e)&&p?.openRowSheet(m.current?.()??[])},onKeyDown:e=>{u?.(e),!e.defaultPrevented&&e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),p?.openRowSheet(m.current?.()??[]))}}:{onClick:l,onKeyDown:u};return(0,o.jsx)(n.TableRowActionsRegistryContext.Provider,{value:_,children:(0,o.jsx)(`tr`,{...d,...v,ref:f,"data-slot":c,"data-state":s,className:t.cn(i.tableRowVariants(),e)})})}),d=a.forwardRef(function({className:e,align:n,ariaSort:r,...a},s){return(0,o.jsx)(`th`,{"aria-sort":r,...a,ref:s,"data-slot":`table-head`,className:t.cn(i.tableHeadVariants({align:n}),e)})}),f=a.forwardRef(function({className:e,align:n,...r},a){return(0,o.jsx)(`td`,{...r,ref:a,"data-slot":`table-cell`,className:t.cn(i.tableCellVariants({align:n}),e)})});s.displayName=`TableHeader`,c.displayName=`TableBody`,l.displayName=`TableFooter`,u.displayName=`TableRow`,d.displayName=`TableHead`,f.displayName=`TableCell`,exports.TableBody=c,exports.TableCell=f,exports.TableFooter=l,exports.TableHead=d,exports.TableHeader=s,exports.TableRow=u;
|
|
@@ -1,54 +1,76 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn as e } from "../../lib/utils.js";
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
3
|
+
import { TableActionsContext as t, TableRowActionsRegistryContext as n } from "./TableActionsContext.js";
|
|
4
|
+
import { isInsideInteractiveControl as r } from "./Table.utils.js";
|
|
5
|
+
import { tableBodyVariants as i, tableCellVariants as a, tableFooterVariants as o, tableHeadVariants as s, tableHeaderVariants as c, tableRowVariants as l } from "./Table.variant.js";
|
|
6
|
+
import * as u from "react";
|
|
7
|
+
import { jsx as d } from "react/jsx-runtime";
|
|
6
8
|
//#region src/components/Table/TableParts.tsx
|
|
7
|
-
var
|
|
8
|
-
return /* @__PURE__ */
|
|
9
|
+
var f = u.forwardRef(function({ className: t, ...n }, r) {
|
|
10
|
+
return /* @__PURE__ */ d("thead", {
|
|
9
11
|
...n,
|
|
10
12
|
ref: r,
|
|
11
13
|
"data-slot": "table-header",
|
|
12
|
-
className: e(
|
|
14
|
+
className: e(c(), t)
|
|
13
15
|
});
|
|
14
|
-
}),
|
|
15
|
-
return /* @__PURE__ */
|
|
16
|
-
...
|
|
17
|
-
ref:
|
|
16
|
+
}), p = u.forwardRef(function({ className: t, ...n }, r) {
|
|
17
|
+
return /* @__PURE__ */ d("tbody", {
|
|
18
|
+
...n,
|
|
19
|
+
ref: r,
|
|
18
20
|
"data-slot": "table-body",
|
|
19
|
-
className: e(
|
|
21
|
+
className: e(i(), t)
|
|
20
22
|
});
|
|
21
|
-
}),
|
|
22
|
-
return /* @__PURE__ */
|
|
23
|
+
}), m = u.forwardRef(function({ className: t, ...n }, r) {
|
|
24
|
+
return /* @__PURE__ */ d("tfoot", {
|
|
23
25
|
...n,
|
|
24
|
-
ref:
|
|
26
|
+
ref: r,
|
|
25
27
|
"data-slot": "table-footer",
|
|
26
|
-
className: e(r(), t)
|
|
27
|
-
});
|
|
28
|
-
}), f = s.forwardRef(function({ className: t, state: n, slot: r = "table-row", ...i }, a) {
|
|
29
|
-
return /* @__PURE__ */ c("tr", {
|
|
30
|
-
...i,
|
|
31
|
-
ref: a,
|
|
32
|
-
"data-slot": r,
|
|
33
|
-
"data-state": n,
|
|
34
28
|
className: e(o(), t)
|
|
35
29
|
});
|
|
36
|
-
}),
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"
|
|
42
|
-
|
|
30
|
+
}), h = u.forwardRef(function({ className: i, state: a, slot: o = "table-row", onClick: s, onKeyDown: c, ...f }, p) {
|
|
31
|
+
let m = u.useContext(t), h = u.useRef(null), [g, _] = u.useState(!1), v = u.useMemo(() => ({ register: (e) => {
|
|
32
|
+
h.current = e, _(e !== null);
|
|
33
|
+
} }), []), y = g && m?.isMobile === !0 ? {
|
|
34
|
+
tabIndex: 0,
|
|
35
|
+
"aria-haspopup": "dialog",
|
|
36
|
+
"data-actionable": "true",
|
|
37
|
+
onClick: (e) => {
|
|
38
|
+
s?.(e), !e.defaultPrevented && !r(e) && m?.openRowSheet(h.current?.() ?? []);
|
|
39
|
+
},
|
|
40
|
+
onKeyDown: (e) => {
|
|
41
|
+
c?.(e), !e.defaultPrevented && e.target === e.currentTarget && (e.key === "Enter" || e.key === " ") && (e.preventDefault(), m?.openRowSheet(h.current?.() ?? []));
|
|
42
|
+
}
|
|
43
|
+
} : {
|
|
44
|
+
onClick: s,
|
|
45
|
+
onKeyDown: c
|
|
46
|
+
};
|
|
47
|
+
return /* @__PURE__ */ d(n.Provider, {
|
|
48
|
+
value: v,
|
|
49
|
+
children: /* @__PURE__ */ d("tr", {
|
|
50
|
+
...f,
|
|
51
|
+
...y,
|
|
52
|
+
ref: p,
|
|
53
|
+
"data-slot": o,
|
|
54
|
+
"data-state": a,
|
|
55
|
+
className: e(l(), i)
|
|
56
|
+
})
|
|
43
57
|
});
|
|
44
|
-
}),
|
|
45
|
-
return /* @__PURE__ */
|
|
58
|
+
}), g = u.forwardRef(function({ className: t, align: n, ariaSort: r, ...i }, a) {
|
|
59
|
+
return /* @__PURE__ */ d("th", {
|
|
60
|
+
"aria-sort": r,
|
|
46
61
|
...i,
|
|
47
62
|
ref: a,
|
|
63
|
+
"data-slot": "table-head",
|
|
64
|
+
className: e(s({ align: n }), t)
|
|
65
|
+
});
|
|
66
|
+
}), _ = u.forwardRef(function({ className: t, align: n, ...r }, i) {
|
|
67
|
+
return /* @__PURE__ */ d("td", {
|
|
68
|
+
...r,
|
|
69
|
+
ref: i,
|
|
48
70
|
"data-slot": "table-cell",
|
|
49
|
-
className: e(
|
|
71
|
+
className: e(a({ align: n }), t)
|
|
50
72
|
});
|
|
51
73
|
});
|
|
52
|
-
|
|
74
|
+
f.displayName = "TableHeader", p.displayName = "TableBody", m.displayName = "TableFooter", h.displayName = "TableRow", g.displayName = "TableHead", _.displayName = "TableCell";
|
|
53
75
|
//#endregion
|
|
54
|
-
export {
|
|
76
|
+
export { p as TableBody, _ as TableCell, m as TableFooter, g as TableHead, f as TableHeader, h as TableRow };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";const e=require(`../../_virtual/_rolldown/runtime.cjs`),t=require(`../../config/useZuiConfig.cjs`),n=require(`../../lib/utils.cjs`),r=require(`../shared/FieldClearButton.cjs`),i=require(`../shared/IconActionButton.cjs`),a=require(`./TableActionsContext.cjs`),o=require(`./Table.constants.cjs`),s=require(`./TableParts.cjs`);let c=require(`react`);c=e.__toESM(c,1);let l=require(`react/jsx-runtime`),u=require(`lucide-react`);var d={};function f(e){return(0,l.jsx)(`span`,{className:n.cn(`zui:inline-flex`,r.CLEAR_ICON_CLASS,`zui:[&>svg]:size-full`),children:e})}var p=c.forwardRef(function({row:e=d,rowIndex:r=0,rowId:p,onEdit:m,onDelete:h,editAction:g,deleteAction:_,actions:v,className:y},b){let{messages:x}=t.useZuiConfig(),S=c.useContext(a.TableActionsContext),C=c.useContext(a.TableRowActionsRegistryContext),w=S?.isMobile??!1,T=S?.isBusy??!1,E=[];m&&!g?.hidden&&E.push({key:`edit`,label:g?.tooltip??x.common.edit,icon:g?.icon??(0,l.jsx)(u.Pencil,{className:`zui:size-4`,"aria-hidden":`true`}),className:g?.className,danger:!1,disabled:g?.disabled??!1,onClick:m}),(v??[]).forEach((e,t)=>{e.hidden||E.push({key:`custom-${t}`,label:e.tooltip,icon:e.icon,className:e.className,danger:e.danger??!1,disabled:e.disabled??!1,onClick:e.onClick})}),h&&!_?.hidden&&E.push({key:`delete`,label:_?.tooltip??x.common.delete,icon:_?.icon??(0,l.jsx)(u.Trash2,{className:`zui:size-4`,"aria-hidden":`true`}),className:_?.className,danger:!0,disabled:_?.disabled??!1,onClick:h});let D=t=>{let n={row:e,rowIndex:r,rowId:p},i=()=>t.onClick(n);return S?S.run(i):Promise.resolve(i())},O=()=>E.map(e=>({key:e.key,label:e.label,icon:f(e.icon),danger:e.danger,disabled:e.disabled,onSelect:()=>void D(e)})),k=c.useRef(O);c.useLayoutEffect(()=>{k.current=O});let A=E.length>0;return c.useLayoutEffect(()=>{if(!(!w||!C||!A))return C.register(()=>k.current()),()=>C.register(null)},[A,w,C]),w?null:(0,l.jsx)(s.TableCell,{ref:b,align:`center`,"data-cell":`actions`,className:n.cn(o.actionsColumnClassName,o.actionsColumnStickyClassName,y),children:(0,l.jsx)(`div`,{"data-slot":`table-row-actions`,className:`zui:flex zui:items-center zui:justify-center zui:gap-0.5`,children:E.map(e=>(0,l.jsx)(i.IconActionButton,{"data-slot":e.key===`edit`?`table-action-edit-button`:e.key===`delete`?`table-action-delete-button`:`table-action-custom-button`,label:e.label,icon:e.icon,disabled:T||e.disabled,className:n.cn(o.rowActionButtonClassName,e.danger?`zui:text-[var(--zui-theme-status-danger)]`:`zui:text-[var(--zui-theme-text-primary)]`,e.className),onClick:()=>void D(e)},e.key))})})}),m=c.forwardRef(function({className:e,children:r,...i},u){let{messages:d}=t.useZuiConfig();return c.useContext(a.TableActionsContext)?.isMobile?null:(0,l.jsx)(s.TableHead,{...i,ref:u,align:`center`,className:n.cn(`zui:w-32`,o.actionsColumnClassName,o.actionsColumnStickyClassName,e),children:r??d.table.actions})});p.displayName=`TableRowActions`,m.displayName=`TableActionsHead`,exports.TableActionsHead=m,exports.TableRowActions=p;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { TableActionsHeadProps, TableRowActionsProps } from "./Table.interface.cjs";
|
|
3
|
+
/**
|
|
4
|
+
* The actions cell of a row in a hand-written table (`<Table>` with children): the built-in edit and
|
|
5
|
+
* delete buttons, plus any custom actions with their own icon, tooltip, styling and handler. Place
|
|
6
|
+
* it as the last cell of a `TableRow`, under a `TableActionsHead`. It behaves like the actions
|
|
7
|
+
* column of a schema table: one action runs at a time and all are disabled while the table is
|
|
8
|
+
* mutating. Below the mobile breakpoint it draws nothing; tapping the card opens the same actions
|
|
9
|
+
* as a sheet.
|
|
10
|
+
*/
|
|
11
|
+
declare const TableRowActions: React.ForwardRefExoticComponent<TableRowActionsProps & React.RefAttributes<HTMLTableCellElement>>;
|
|
12
|
+
/** The header cell for a `TableRowActions` column; draws nothing below the mobile breakpoint. */
|
|
13
|
+
declare const TableActionsHead: React.ForwardRefExoticComponent<TableActionsHeadProps & React.RefAttributes<HTMLTableCellElement>>;
|
|
14
|
+
export { TableActionsHead, TableRowActions };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { TableActionsHeadProps, TableRowActionsProps } from "./Table.interface.js";
|
|
3
|
+
/**
|
|
4
|
+
* The actions cell of a row in a hand-written table (`<Table>` with children): the built-in edit and
|
|
5
|
+
* delete buttons, plus any custom actions with their own icon, tooltip, styling and handler. Place
|
|
6
|
+
* it as the last cell of a `TableRow`, under a `TableActionsHead`. It behaves like the actions
|
|
7
|
+
* column of a schema table: one action runs at a time and all are disabled while the table is
|
|
8
|
+
* mutating. Below the mobile breakpoint it draws nothing; tapping the card opens the same actions
|
|
9
|
+
* as a sheet.
|
|
10
|
+
*/
|
|
11
|
+
declare const TableRowActions: React.ForwardRefExoticComponent<TableRowActionsProps & React.RefAttributes<HTMLTableCellElement>>;
|
|
12
|
+
/** The header cell for a `TableRowActions` column; draws nothing below the mobile breakpoint. */
|
|
13
|
+
declare const TableActionsHead: React.ForwardRefExoticComponent<TableActionsHeadProps & React.RefAttributes<HTMLTableCellElement>>;
|
|
14
|
+
export { TableActionsHead, TableRowActions };
|