najm-kit 2.1.20 → 2.1.21

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.
Files changed (2) hide show
  1. package/dist/index.mjs +56 -32
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -3,7 +3,7 @@ import React__default, { createContext, useContext, useCallback, useEffect, useS
3
3
  import { Slot } from '@radix-ui/react-slot';
4
4
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
5
5
  import * as LucideIcons from 'lucide-react';
6
- import { ChevronDown, AlertTriangle, RefreshCw, LoaderCircleIcon, X, XIcon, Menu, Search, ChevronRightIcon, CheckIcon, CircleIcon, ChevronDownIcon, ChevronUpIcon, ChevronLeftIcon, SearchIcon, Table as Table$1, FileJson, ChevronRight, CheckSquare, FilePlus, FolderPlus, Trash2, Share2, Move, ClipboardPaste, Copy, Scissors, Pencil, Download, Eye, ArrowUpDown, Loader2, ChevronUp, Folder, EyeOff, ChevronsUpDown, Check, Calendar as Calendar$1, FileUp, UploadCloud, CheckCircle2, AlertCircle, Star, Globe, Clock, Upload, Plus, MoreVertical, Edit, ChevronsLeft, ChevronLeft, ChevronsRight, Merge, PanelLeftOpen, PanelLeftClose, LogOut, Image, ArrowUp, ArrowDown, LoaderPinwheelIcon, LoaderIcon, ArrowUpRight, ArrowDownRight, SlidersHorizontal, Columns3, Settings, SearchX, Inbox, List, LayoutGrid, Code, FolderOpen } from 'lucide-react';
6
+ import { ChevronDown, AlertTriangle, RefreshCw, LoaderCircleIcon, X, XIcon, Menu, Search, ChevronRightIcon, CheckIcon, CircleIcon, ChevronDownIcon, ChevronUpIcon, ChevronLeftIcon, SearchIcon, Table as Table$1, FileJson, ChevronRight, CheckSquare, FilePlus, FolderPlus, Trash2, Share2, Move, ClipboardPaste, Copy, Scissors, Pencil, Download, Eye, ArrowUpDown, Loader2, ChevronUp, Folder, EyeOff, ChevronsUpDown, Check, Calendar as Calendar$1, FileUp, UploadCloud, CheckCircle2, AlertCircle, Star, Globe, Clock, Upload, Plus, MoreVertical, Edit, ChevronsLeft, ChevronLeft, ChevronsRight, Merge, PanelLeftOpen, PanelLeftClose, LogOut, Image, ArrowUp, ArrowDown, LoaderPinwheelIcon, LoaderIcon, ArrowUpRight, ArrowDownRight, SlidersHorizontal, Columns3, Settings, Filter, SearchX, Inbox, List, LayoutGrid, Code, FolderOpen } from 'lucide-react';
7
7
  import { cva } from 'class-variance-authority';
8
8
  import { clsx } from 'clsx';
9
9
  import { twMerge } from 'tailwind-merge';
@@ -9978,12 +9978,12 @@ function SearchFilter({ placeholder }) {
9978
9978
  const value = table.getState().globalFilter ?? "";
9979
9979
  return /* @__PURE__ */ jsx(TextInput, { icon: Search, value, onChange: (v) => table.setGlobalFilter(v), placeholder: placeholder ?? "Search\u2026", bordered });
9980
9980
  }
9981
- function TextFilter({ name, placeholder }) {
9981
+ function TextFilter({ name, placeholder, icon }) {
9982
9982
  const table = useTableStore.use.table();
9983
9983
  const bordered = useTableStore.use.bordered();
9984
9984
  const column = table?.getColumn?.(name);
9985
9985
  if (!column) return null;
9986
- return /* @__PURE__ */ jsx(TextInput, { value: column.getFilterValue() ?? "", onChange: (value) => column.setFilterValue(value), placeholder, bordered });
9986
+ return /* @__PURE__ */ jsx(TextInput, { icon, value: column.getFilterValue() ?? "", onChange: (value) => column.setFilterValue(value), placeholder, bordered });
9987
9987
  }
9988
9988
  function SelectFilter({ name, options, placeholder, inputType }) {
9989
9989
  const table = useTableStore.use.table();
@@ -9997,7 +9997,7 @@ function SelectFilter({ name, options, placeholder, inputType }) {
9997
9997
  function defaultWrapperClass(filter) {
9998
9998
  return filter.type === "search" ? "flex-1 min-w-[160px] max-w-sm" : "w-full sm:w-40 xl:w-56 shrink-0";
9999
9999
  }
10000
- function RenderFilter({ filter }) {
10000
+ function RenderFilter({ filter, mobilePrimary = false }) {
10001
10001
  const table = useTableStore.use.table();
10002
10002
  const bordered = useTableStore.use.bordered();
10003
10003
  if (filter.type === "search") {
@@ -10020,6 +10020,7 @@ function RenderFilter({ filter }) {
10020
10020
  return /* @__PURE__ */ jsx(
10021
10021
  TextInput,
10022
10022
  {
10023
+ icon: mobilePrimary ? Search : void 0,
10023
10024
  value: filter.value ?? "",
10024
10025
  onChange: filter.onChange,
10025
10026
  placeholder: filter.placeholder,
@@ -10062,7 +10063,7 @@ function RenderFilter({ filter }) {
10062
10063
  );
10063
10064
  }
10064
10065
  if (filter.type === "text") {
10065
- return /* @__PURE__ */ jsx(TextFilter, { name: filter.name, placeholder: filter.placeholder });
10066
+ return /* @__PURE__ */ jsx(TextFilter, { name: filter.name, placeholder: filter.placeholder, icon: mobilePrimary ? Search : void 0 });
10066
10067
  }
10067
10068
  if (!table) return null;
10068
10069
  return /* @__PURE__ */ jsx(SelectFilter, { name: filter.name, options: filter.options || [], placeholder: filter.placeholder, inputType: filter.type });
@@ -10070,7 +10071,7 @@ function RenderFilter({ filter }) {
10070
10071
  function TableFilters() {
10071
10072
  const filters = useTableStore.use.filters();
10072
10073
  if (!filters?.length) return null;
10073
- return /* @__PURE__ */ jsx("div", { className: "flex flex-wrap items-center gap-2 flex-1 min-w-0", children: filters.map((filter) => /* @__PURE__ */ jsx(
10074
+ return /* @__PURE__ */ jsx("div", { "data-ntable-desktop-filters": true, className: "hidden flex-1 min-w-0 flex-wrap items-center gap-2 md:flex", children: filters.map((filter) => /* @__PURE__ */ jsx(
10074
10075
  "div",
10075
10076
  {
10076
10077
  className: cn(defaultWrapperClass(filter), filter.className),
@@ -10079,7 +10080,7 @@ function TableFilters() {
10079
10080
  filter.name
10080
10081
  )) });
10081
10082
  }
10082
- function TableAddButton() {
10083
+ function TableAddButton({ mobile = false }) {
10083
10084
  const onAddClick = useTableStore.use.onAddClick();
10084
10085
  const showAddButton = useTableStore.use.showAddButton();
10085
10086
  const addButtonText = useTableStore.use.addButtonText();
@@ -10087,7 +10088,7 @@ function TableAddButton() {
10087
10088
  const headerTextColor = useTableStore.use.headerTextColor();
10088
10089
  const bordered = useTableStore.use.bordered();
10089
10090
  if (!showAddButton) return null;
10090
- const btnStyle = {
10091
+ const btnStyle = mobile ? { color: resolveTableColor(headerColor, DEFAULT_TABLE_HEADER_COLOR) } : {
10091
10092
  backgroundColor: resolveTableColor(headerColor, DEFAULT_TABLE_HEADER_COLOR),
10092
10093
  color: resolveTableColor(headerTextColor, DEFAULT_TABLE_HEADER_TEXT_COLOR)
10093
10094
  };
@@ -10100,12 +10101,53 @@ function TableAddButton() {
10100
10101
  style: btnStyle,
10101
10102
  "aria-label": addButtonText || "Create",
10102
10103
  title: addButtonText || "Create",
10103
- "data-bordered": bordered ? "true" : void 0,
10104
- className: `h-10 w-10 shrink-0 cursor-pointer flex items-center justify-center rounded-lg transition-opacity hover:opacity-90 ${borderedCls}`,
10104
+ "data-bordered": bordered === false ? "false" : "true",
10105
+ className: cn(
10106
+ "h-10 w-10 shrink-0 cursor-pointer items-center justify-center rounded-lg transition-colors hover:opacity-90",
10107
+ mobile ? cn("flex bg-card md:hidden", bordered === false ? "shadow-sm" : "border border-input hover:border-primary/70") : `hidden md:flex ${borderedCls}`
10108
+ ),
10105
10109
  children: /* @__PURE__ */ jsx(Plus, { className: "h-5 w-5" })
10106
10110
  }
10107
10111
  );
10108
10112
  }
10113
+ function MobileFiltersMenu({ filters }) {
10114
+ const bordered = useTableStore.use.bordered();
10115
+ if (!filters.length) return null;
10116
+ return /* @__PURE__ */ jsxs(Popover, { children: [
10117
+ /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
10118
+ "button",
10119
+ {
10120
+ type: "button",
10121
+ "aria-label": "Filters",
10122
+ title: "Filters",
10123
+ "data-bordered": bordered === false ? "false" : "true",
10124
+ className: cn(
10125
+ "flex h-10 w-10 shrink-0 cursor-pointer items-center justify-center rounded-lg bg-card text-primary transition-colors hover:border-primary/70",
10126
+ bordered === false ? "shadow-sm" : "border border-input"
10127
+ ),
10128
+ children: /* @__PURE__ */ jsx(Filter, { className: "h-5 w-5" })
10129
+ }
10130
+ ) }),
10131
+ /* @__PURE__ */ jsx(
10132
+ PopoverContent,
10133
+ {
10134
+ align: "end",
10135
+ "aria-label": "Table filters",
10136
+ className: "w-[min(20rem,calc(100vw-2rem))] space-y-3 bg-card p-3",
10137
+ children: filters.map((filter) => /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsx(RenderFilter, { filter }) }, filter.name))
10138
+ }
10139
+ )
10140
+ ] });
10141
+ }
10142
+ function TableMobileToolbar() {
10143
+ const filters = useTableStore.use.filters();
10144
+ const firstFilter = filters?.[0];
10145
+ return /* @__PURE__ */ jsxs("div", { "data-ntable-mobile-toolbar": true, className: "flex w-full min-w-0 items-center gap-2 md:hidden", children: [
10146
+ firstFilter && /* @__PURE__ */ jsx("div", { "data-ntable-mobile-primary-filter": true, className: "min-w-0 flex-1", children: /* @__PURE__ */ jsx(RenderFilter, { filter: firstFilter, mobilePrimary: true }) }),
10147
+ /* @__PURE__ */ jsx(MobileFiltersMenu, { filters: filters?.slice(1) ?? [] }),
10148
+ /* @__PURE__ */ jsx(TableAddButton, { mobile: true })
10149
+ ] });
10150
+ }
10109
10151
  function TableSettingsMenu() {
10110
10152
  const showViewToggle = useTableStore.use.showViewToggle();
10111
10153
  const showColumnVisibility = useTableStore.use.showColumnVisibility();
@@ -10195,7 +10237,7 @@ function NTableHeader() {
10195
10237
  headerSlot && /* @__PURE__ */ jsx("div", { className: "flex min-w-0 flex-1 items-center gap-2", children: headerSlot }),
10196
10238
  hasControls && /* @__PURE__ */ jsxs("div", { className: "flex gap-2 shrink-0", children: [
10197
10239
  /* @__PURE__ */ jsx("span", { className: "hidden md:contents", children: /* @__PURE__ */ jsx(TableSettingsMenu, {}) }),
10198
- /* @__PURE__ */ jsx("span", { className: "hidden md:contents", children: /* @__PURE__ */ jsx(TableAddButton, {}) })
10240
+ /* @__PURE__ */ jsx(TableAddButton, {})
10199
10241
  ] })
10200
10242
  ] });
10201
10243
  }
@@ -10206,11 +10248,12 @@ function NTableHeader() {
10206
10248
  const justify = hasControls || headerSlot || hasToolbar ? "justify-between" : "justify-start";
10207
10249
  return /* @__PURE__ */ jsxs("div", { "data-ntable-header": true, className: cn("flex shrink-0 items-center gap-3 flex-wrap lg:flex-nowrap", justify, classNames?.header), children: [
10208
10250
  /* @__PURE__ */ jsx(TableFilters, {}),
10251
+ /* @__PURE__ */ jsx(TableMobileToolbar, {}),
10209
10252
  headerSlot && /* @__PURE__ */ jsx("div", { className: "ml-auto flex shrink-0 items-center gap-2", children: headerSlot }),
10210
10253
  /* @__PURE__ */ jsx(TableToolbarSlot, {}),
10211
10254
  hasControls && /* @__PURE__ */ jsxs("div", { className: "flex gap-2 shrink-0", children: [
10212
10255
  /* @__PURE__ */ jsx("span", { className: "hidden md:contents", children: /* @__PURE__ */ jsx(TableSettingsMenu, {}) }),
10213
- /* @__PURE__ */ jsx("span", { className: "hidden md:contents", children: /* @__PURE__ */ jsx(TableAddButton, {}) })
10256
+ /* @__PURE__ */ jsx(TableAddButton, {})
10214
10257
  ] })
10215
10258
  ] });
10216
10259
  }
@@ -10390,24 +10433,6 @@ function DefaultTableFilteredEmptyState() {
10390
10433
  }
10391
10434
  );
10392
10435
  }
10393
- function TableMobileAddButton() {
10394
- const onAddClick = useTableStore.use.onAddClick();
10395
- const showAddButton = useTableStore.use.showAddButton();
10396
- const addButtonText = useTableStore.use.addButtonText();
10397
- if (!showAddButton || !onAddClick) return null;
10398
- return /* @__PURE__ */ jsx("div", { className: "flex shrink-0 px-2 md:hidden", children: /* @__PURE__ */ jsxs(
10399
- "button",
10400
- {
10401
- type: "button",
10402
- onClick: onAddClick,
10403
- className: "flex w-full items-center justify-center gap-2 rounded-lg bg-primary px-4 py-2.5 text-sm font-medium text-primary-foreground transition-opacity hover:opacity-90",
10404
- children: [
10405
- /* @__PURE__ */ jsx(Plus, { className: "h-4 w-4" }),
10406
- addButtonText || "Add"
10407
- ]
10408
- }
10409
- ) });
10410
- }
10411
10436
  function TableLayout(props) {
10412
10437
  const containerRef = useRef(null);
10413
10438
  const classNames = useTableStore.use.classNames?.();
@@ -10457,8 +10482,7 @@ function TableLayout(props) {
10457
10482
  showEmpty && /* @__PURE__ */ jsx(TableStateSlot, { children: props.renderEmpty ? props.renderEmpty() : /* @__PURE__ */ jsx(DefaultTableEmptyState, { title: noDataText }) }),
10458
10483
  /* @__PURE__ */ jsx(NTableContent, { effectiveMode }),
10459
10484
  /* @__PURE__ */ jsx(NTableCards, { effectiveMode }),
10460
- /* @__PURE__ */ jsx(NTableJson, {}),
10461
- /* @__PURE__ */ jsx(TableMobileAddButton, {})
10485
+ /* @__PURE__ */ jsx(NTableJson, {})
10462
10486
  ] }) }),
10463
10487
  /* @__PURE__ */ jsx("div", { "data-ntable-pagination": true, className: "min-w-0 shrink-0 bg-background text-foreground", children: /* @__PURE__ */ jsx(NTablePagination, {}) })
10464
10488
  ] });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "najm-kit",
3
- "version": "2.1.20",
3
+ "version": "2.1.21",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "Reusable React UI component package for Najm framework",