@egose/shadcn-theme-ng-tw 0.6.1 → 0.6.2

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.
@@ -156,7 +156,7 @@ Key `EgDataTable` inputs: `columns` (required), `gridColumns`, `data` (array, or
156
156
 
157
157
  Outputs: `selectionChange` (also fires once on init, mirroring React's mount effect), `pageChange`, `pageSizeChange`, `rowClick`, `sortingChange`, `columnFiltersChange`, `filterChange` (toolbar input string), `columnVisibilityChange`.
158
158
 
159
- The toolbar (`showToolbar`) always renders the filter input: with `filterColumnId` it filters that column client-side (and `filterChange` mirrors the string); without it, keystrokes only emit `filterChange` so the caller can filter server-side. The column-visibility dropdown is opt-in via `showColumnToggle` (default `false`). `toolbarActions` takes an `ng-template` rendered on the right side of the toolbar row (built-ins stay left) — it renders the row even when `showToolbar` is false.
159
+ The toolbar (`showToolbar`) always renders the filter input: with `filterColumnId` it filters that column client-side (and `filterChange` mirrors the string); without it, keystrokes only emit `filterChange` so the caller can filter server-side. The column-visibility dropdown is opt-in via `showColumnToggle` (default `false`, requires `showToolbar`). `showColumnToggle` also enables hiding: the `Hide` item in `EgDataTableColumnHeader` only renders when it is true (TanStack `column.getCanHide()`), so a hidden column always has a way back via View; per-column `enableHiding: false` disables individual columns even then. `toolbarActions` takes an `ng-template` rendered on the right side of the toolbar row (built-ins stay left) — it renders the row even when `showToolbar` is false.
160
160
 
161
161
  `size` scales spatial density one step down/up (`sm`: `h-8` headers, `p-1` cells, `h-7` buttons; `lg`: `h-12` headers, `p-3` cells, `h-9` buttons; filter input, page-size trigger, and pager meta texts follow). `EgDataTableColumnHeader` (consumer-instantiated via `flexRenderComponent`) takes the same `size` — for reactive updates put every input in `bindings` (`inputBinding('size', ...)`, plus `column`/`title`, since `bindings` cannot mix with `inputs`).
162
162
 
@@ -368,7 +368,7 @@ class EgDataTableViewOptions {
368
368
  type="button"
369
369
  [hlmDropdownMenuTrigger]="_menu"
370
370
  >
371
- <ng-icon hlm name="lucideSettings2" />
371
+ <ng-icon hlm size="sm" name="lucideSettings2" />
372
372
  View
373
373
  </button>
374
374
  <ng-template #_menu>
@@ -406,7 +406,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImpor
406
406
  type="button"
407
407
  [hlmDropdownMenuTrigger]="_menu"
408
408
  >
409
- <ng-icon hlm name="lucideSettings2" />
409
+ <ng-icon hlm size="sm" name="lucideSettings2" />
410
410
  View
411
411
  </button>
412
412
  <ng-template #_menu>
@@ -560,7 +560,7 @@ class EgDataTable {
560
560
  ...(ngDevMode ? [{ debugName: "filterColumnId" }] : /* istanbul ignore next */ []));
561
561
  filterPlaceholder = input('Filter...', /* @ts-ignore */
562
562
  ...(ngDevMode ? [{ debugName: "filterPlaceholder" }] : /* istanbul ignore next */ []));
563
- /** Show the column-visibility dropdown inside the toolbar. Off by default; opt in per table. */
563
+ /** Show the column-visibility dropdown inside the toolbar (requires `showToolbar`). Off by default; opt in per table. Also enables hiding — the `Hide` item in `EgDataTableColumnHeader` only renders when this is true, so hidden columns always have a way back. Per-column `enableHiding: false` further disables individual columns. */
564
564
  showColumnToggle = input(false, /* @ts-ignore */
565
565
  ...(ngDevMode ? [{ debugName: "showColumnToggle" }] : /* istanbul ignore next */ []));
566
566
  /** Custom right-side toolbar content (e.g. action buttons) as a template. Renders the toolbar row even when `showToolbar` is false; built-ins stay on the left. */
@@ -722,6 +722,10 @@ class EgDataTable {
722
722
  columns: this._finalColumns(),
723
723
  data: this._tableItems(),
724
724
  getRowId: this.getRowId(),
725
+ // Hiding is only allowed when the View menu can bring columns back.
726
+ // This drives `column.getCanHide()` for both `EgDataTableColumnHeader`
727
+ // (Hide item) and `EgDataTableViewOptions` (toggle list).
728
+ enableHiding: this.showColumnToggle(),
725
729
  manualPagination: server,
726
730
  manualSorting: server,
727
731
  manualFiltering: server,
@@ -1324,7 +1328,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImpor
1324
1328
  *
1325
1329
  * Render via `flexRenderComponent(EgDataTableColumnHeader, { inputs: { column, title } })`
1326
1330
  * so the extra `title` input flows alongside the flex-render `column` context.
1327
- * Non-sortable columns render a plain label.
1331
+ * Non-sortable columns render a plain label. The `Hide` menu item only renders
1332
+ * when `column.getCanHide()` is true — `EgDataTable` ties table-level
1333
+ * `enableHiding` to its `showColumnToggle` input so there is always a way back
1334
+ * via the View menu, and per-column `enableHiding: false` further disables it.
1328
1335
  */
1329
1336
  class EgDataTableColumnHeader {
1330
1337
  column = input.required(/* @ts-ignore */
@@ -1336,6 +1343,9 @@ class EgDataTableColumnHeader {
1336
1343
  ...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
1337
1344
  _sorted = computed(() => this.column().getIsSorted(), /* @ts-ignore */
1338
1345
  ...(ngDevMode ? [{ debugName: "_sorted" }] : /* istanbul ignore next */ []));
1346
+ /** Hideable only when TanStack allows it (table + column `enableHiding`). Absent `getCanHide` (legacy mocks) means hideable. */
1347
+ _canHide = computed(() => this.column().getCanHide?.() ?? true, /* @ts-ignore */
1348
+ ...(ngDevMode ? [{ debugName: "_canHide" }] : /* istanbul ignore next */ []));
1339
1349
  /** Height per density. Merged by `hlmButton`. */
1340
1350
  _buttonClass = computed(() => hlm('tw:-ml-3', this.size() === 'sm' ? 'tw:h-7' : this.size() === 'lg' ? 'tw:h-9' : 'tw:h-8'), /* @ts-ignore */
1341
1351
  ...(ngDevMode ? [{ debugName: "_buttonClass" }] : /* istanbul ignore next */ []));
@@ -1374,11 +1384,13 @@ class EgDataTableColumnHeader {
1374
1384
  <ng-icon hlm size="sm" name="lucideArrowDown" />
1375
1385
  Desc
1376
1386
  </button>
1377
- <div hlmDropdownMenuSeparator></div>
1378
- <button hlmDropdownMenuItem type="button" (click)="column().toggleVisibility(false)">
1379
- <ng-icon hlm size="sm" name="lucideEyeOff" />
1380
- Hide
1381
- </button>
1387
+ @if (_canHide()) {
1388
+ <div hlmDropdownMenuSeparator></div>
1389
+ <button hlmDropdownMenuItem type="button" (click)="column().toggleVisibility(false)">
1390
+ <ng-icon hlm size="sm" name="lucideEyeOff" />
1391
+ Hide
1392
+ </button>
1393
+ }
1382
1394
  </div>
1383
1395
  </ng-template>
1384
1396
  </div>
@@ -1427,11 +1439,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImpor
1427
1439
  <ng-icon hlm size="sm" name="lucideArrowDown" />
1428
1440
  Desc
1429
1441
  </button>
1430
- <div hlmDropdownMenuSeparator></div>
1431
- <button hlmDropdownMenuItem type="button" (click)="column().toggleVisibility(false)">
1432
- <ng-icon hlm size="sm" name="lucideEyeOff" />
1433
- Hide
1434
- </button>
1442
+ @if (_canHide()) {
1443
+ <div hlmDropdownMenuSeparator></div>
1444
+ <button hlmDropdownMenuItem type="button" (click)="column().toggleVisibility(false)">
1445
+ <ng-icon hlm size="sm" name="lucideEyeOff" />
1446
+ Hide
1447
+ </button>
1448
+ }
1435
1449
  </div>
1436
1450
  </ng-template>
1437
1451
  </div>
@@ -237,7 +237,7 @@ declare class EgDataTable<TData extends RowData> implements OnInit {
237
237
  /** Column id the toolbar filter input writes to (e.g. `'email'`). Empty means client-side filtering is skipped and keystrokes only emit `filterChange` (server-side pattern). */
238
238
  readonly filterColumnId: _angular_core.InputSignal<string>;
239
239
  readonly filterPlaceholder: _angular_core.InputSignal<string>;
240
- /** Show the column-visibility dropdown inside the toolbar. Off by default; opt in per table. */
240
+ /** Show the column-visibility dropdown inside the toolbar (requires `showToolbar`). Off by default; opt in per table. Also enables hiding — the `Hide` item in `EgDataTableColumnHeader` only renders when this is true, so hidden columns always have a way back. Per-column `enableHiding: false` further disables individual columns. */
241
241
  readonly showColumnToggle: _angular_core.InputSignal<boolean>;
242
242
  /** Custom right-side toolbar content (e.g. action buttons) as a template. Renders the toolbar row even when `showToolbar` is false; built-ins stay on the left. */
243
243
  readonly toolbarActions: _angular_core.InputSignal<TemplateRef<unknown> | undefined>;
@@ -381,13 +381,18 @@ interface EgSortableColumn {
381
381
  getIsSorted(): false | SortDirection;
382
382
  toggleSorting(desc?: boolean): void;
383
383
  toggleVisibility(value?: boolean): void;
384
+ /** Whether the column can be hidden (`columnDef.enableHiding` and table `enableHiding`). Optional for back-compat mocks — absent means hideable. */
385
+ getCanHide?(): boolean;
384
386
  }
385
387
  /**
386
388
  * Sortable + hideable column header.
387
389
  *
388
390
  * Render via `flexRenderComponent(EgDataTableColumnHeader, { inputs: { column, title } })`
389
391
  * so the extra `title` input flows alongside the flex-render `column` context.
390
- * Non-sortable columns render a plain label.
392
+ * Non-sortable columns render a plain label. The `Hide` menu item only renders
393
+ * when `column.getCanHide()` is true — `EgDataTable` ties table-level
394
+ * `enableHiding` to its `showColumnToggle` input so there is always a way back
395
+ * via the View menu, and per-column `enableHiding: false` further disables it.
391
396
  */
392
397
  declare class EgDataTableColumnHeader {
393
398
  readonly column: _angular_core.InputSignal<EgSortableColumn>;
@@ -395,6 +400,8 @@ declare class EgDataTableColumnHeader {
395
400
  /** Density of the trigger button. */
396
401
  readonly size: _angular_core.InputSignal<HlmTableSize>;
397
402
  protected readonly _sorted: _angular_core.Signal<false | SortDirection>;
403
+ /** Hideable only when TanStack allows it (table + column `enableHiding`). Absent `getCanHide` (legacy mocks) means hideable. */
404
+ protected readonly _canHide: _angular_core.Signal<boolean>;
398
405
  /** Height per density. Merged by `hlmButton`. */
399
406
  protected readonly _buttonClass: _angular_core.Signal<string>;
400
407
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<EgDataTableColumnHeader, never>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@egose/shadcn-theme-ng-tw",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "description": "Angular shadcn UI theme",
5
5
  "author": "Junmin Ahn",
6
6
  "bundles": [