@vinorcola/dynamic-table 1.4.0 → 1.4.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.
@@ -1,10 +1,14 @@
1
- import type { ReactNode } from "react";
2
- import type { Primitive } from "./index.ts";
1
+ import type { FC, ReactNode } from "react";
2
+ import type { Primitive } from "./index.js";
3
3
  export interface DictionaryEntry {
4
4
  title: string;
5
5
  prepend?: ReactNode;
6
6
  }
7
+ export type DictinaryValueWrapper = FC<{
8
+ children: ReactNode;
9
+ }>;
7
10
  export default class Dictionary<Value extends Primitive> extends Map<Value, DictionaryEntry> {
8
11
  readonly unknownMessage: string;
9
- constructor(unknownMessage: string, entries?: readonly (readonly [Value, DictionaryEntry])[] | null);
12
+ readonly valueWrapper: DictinaryValueWrapper;
13
+ constructor(unknownMessage: string, entries?: readonly (readonly [Value, DictionaryEntry])[] | null, valueWrapper?: DictinaryValueWrapper);
10
14
  }
package/lib/Dictionary.js CHANGED
@@ -1,7 +1,9 @@
1
1
  export default class Dictionary extends Map {
2
2
  unknownMessage;
3
- constructor(unknownMessage, entries) {
3
+ valueWrapper;
4
+ constructor(unknownMessage, entries, valueWrapper) {
4
5
  super(entries);
5
6
  this.unknownMessage = unknownMessage;
7
+ this.valueWrapper = valueWrapper ?? ((props) => props.children);
6
8
  }
7
9
  }
package/lib/useItems.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { displayInteger } from "@vinorcola/utils/number";
3
3
  import { extractSearchableText } from "@vinorcola/utils/text";
4
- import { Fragment, useMemo } from "react";
4
+ import { useMemo } from "react";
5
5
  import ValueList from "./ValueList.js";
6
6
  export default function useItems(items, itemTarget, columns, canSelectItem) {
7
7
  return useMemo(() => items.map((item) => ({
@@ -108,7 +108,7 @@ function resolveDisplayableSingleValue(value, dictionary, nodeKey) {
108
108
  if (dictionaryEntry === undefined) {
109
109
  return dictionary.unknownMessage;
110
110
  }
111
- return dictionaryEntry.prepend !== undefined ? (_jsxs(Fragment, { children: [dictionaryEntry.prepend, dictionaryEntry.title] }, nodeKey)) : (dictionaryEntry.title);
111
+ return dictionaryEntry.prepend !== undefined ? (_jsxs(dictionary.valueWrapper, { children: [dictionaryEntry.prepend, dictionaryEntry.title] }, nodeKey)) : (dictionaryEntry.title);
112
112
  }
113
113
  if (typeof value === "boolean") {
114
114
  return value ? "true" : "false";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vinorcola/dynamic-table",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "description": "A table to ease the display of a filterable, sortable and paginable dataset.",
5
5
  "keywords": [
6
6
  "table",