@vuu-ui/vuu-utils 2.2.0 → 2.3.0

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 (33) hide show
  1. package/cjs/packages/vuu-utils/src/array-utils.js +15 -0
  2. package/cjs/packages/vuu-utils/src/array-utils.js.map +1 -1
  3. package/cjs/packages/vuu-utils/src/column-utils.js +0 -15
  4. package/cjs/packages/vuu-utils/src/column-utils.js.map +1 -1
  5. package/cjs/packages/vuu-utils/src/data-editing/EditSession.js +8 -2
  6. package/cjs/packages/vuu-utils/src/data-editing/EditSession.js.map +1 -1
  7. package/cjs/packages/vuu-utils/src/data-editing/useEditableTable.js +14 -4
  8. package/cjs/packages/vuu-utils/src/data-editing/useEditableTable.js.map +1 -1
  9. package/cjs/packages/vuu-utils/src/index.js +5 -1
  10. package/cjs/packages/vuu-utils/src/index.js.map +1 -1
  11. package/cjs/packages/vuu-utils/src/selection-utils.js +31 -0
  12. package/cjs/packages/vuu-utils/src/selection-utils.js.map +1 -1
  13. package/cjs/packages/vuu-utils/src/text-utils.js +5 -0
  14. package/cjs/packages/vuu-utils/src/text-utils.js.map +1 -1
  15. package/esm/packages/vuu-utils/src/array-utils.js +15 -1
  16. package/esm/packages/vuu-utils/src/array-utils.js.map +1 -1
  17. package/esm/packages/vuu-utils/src/column-utils.js +1 -15
  18. package/esm/packages/vuu-utils/src/column-utils.js.map +1 -1
  19. package/esm/packages/vuu-utils/src/data-editing/EditSession.js +8 -2
  20. package/esm/packages/vuu-utils/src/data-editing/EditSession.js.map +1 -1
  21. package/esm/packages/vuu-utils/src/data-editing/useEditableTable.js +14 -4
  22. package/esm/packages/vuu-utils/src/data-editing/useEditableTable.js.map +1 -1
  23. package/esm/packages/vuu-utils/src/index.js +4 -4
  24. package/esm/packages/vuu-utils/src/selection-utils.js +31 -1
  25. package/esm/packages/vuu-utils/src/selection-utils.js.map +1 -1
  26. package/esm/packages/vuu-utils/src/text-utils.js +3 -1
  27. package/esm/packages/vuu-utils/src/text-utils.js.map +1 -1
  28. package/package.json +6 -6
  29. package/types/array-utils.d.ts +8 -0
  30. package/types/column-utils.d.ts +2 -10
  31. package/types/filters/filter-utils.d.ts +1 -1
  32. package/types/selection-utils.d.ts +6 -1
  33. package/types/text-utils.d.ts +8 -0
@@ -2,10 +2,10 @@ export { RestrictToHorizontalAxis } from '../../../node_modules/@dnd-kit/abstrac
2
2
  export { KeyboardSensor, PointerSensor } from '../../../node_modules/@dnd-kit/dom/index.js';
3
3
  export { DragDropProvider, DragOverlay, useInstance } from '../../../node_modules/@dnd-kit/react/index.js';
4
4
  export { useSortable } from '../../../node_modules/@dnd-kit/react/sortable.js';
5
- export { getAddedItems, getMissingItems, itemsChanged, itemsOrOrderChanged, moveItem, moveItemDeprecated, partition } from './array-utils.js';
5
+ export { getAddedItems, getMissingItems, itemsChanged, itemsOrOrderChanged, moveItem, moveItemDeprecated, partition, reorderItems } from './array-utils.js';
6
6
  export { boxContainsPoint, getCenteredBox, getPositionWithinBox, isGridLayoutSplitDirection, pointPositionWithinRect } from './box-utils.js';
7
7
  export { Clock } from './Clock.js';
8
- export { AggregationType, addColumnToSubscribedColumns, applyDefaultColumnConfig, applyGroupByToColumns, applyRuntimeColumnWidthsToConfig, applySortToColumns, applyWidthToColumns, assertAllColumnsAreIncludedInSubscription, buildColumnMap, checkConfirmationPending, columnByAriaIndex, dataAndColumnUnchanged, dataColumnAndKeyUnchanged, dataSourceRowToDataRowDto, existingSort, extractGroupColumn, findColumn, flattenColumnGroup, fromServerDataType, getAllCellsInColumn, getAriaColIndex, getAriaRowIndex, getCalculatedColumnDetails, getColumnLabel, getColumnName, getColumnStyle, getColumnsInViewport, getDefaultAlignment, getDefaultColumnType, getGroupIcon, getGroupValue, getPinStateFromElement, getRuntimeColumnWidth, getServerDataType, getTableHeadings, getTypeFormattingFromColumn, hasCustomRenderer, hasHeadings, hasValidationRules, isCalculatedColumn, isColumnTypeRenderer, isDataLoading, isDateTimeDataType, isDateTimeDataValue, isGroupColumn, isJsonAttribute, isJsonColumn, isJsonGroup, isLookupRenderer, isMappedValueTypeRenderer, isNanoTimestampColumn, isNotHidden, isNumericColumn, isPinned, isResizing, isStringColumn, isTextColumn, isTimeDataType, isTimeDataValue, isTimestampColumn, isTypeDescriptor, isValidColumnAlignment, isValidPinLocation, isValueListRenderer, isVuuColumnDataType, mapSortCriteria, measurePinnedColumns, metadataKeys, moveColumnTo, projectUpdates, removeSort, reorderColumnItems, replaceColumn, setAggregations, setCalculatedColumnExpression, setCalculatedColumnName, setCalculatedColumnType, sortPinnedColumns, subscribedOnly, toColumnDescriptor, toColumnName, toDataSourceColumns, updateColumn, updateColumnFormatting, updateColumnRenderProps, updateColumnType, visibleColumnAtIndex } from './column-utils.js';
8
+ export { AggregationType, addColumnToSubscribedColumns, applyDefaultColumnConfig, applyGroupByToColumns, applyRuntimeColumnWidthsToConfig, applySortToColumns, applyWidthToColumns, assertAllColumnsAreIncludedInSubscription, buildColumnMap, checkConfirmationPending, columnByAriaIndex, dataAndColumnUnchanged, dataColumnAndKeyUnchanged, dataSourceRowToDataRowDto, existingSort, extractGroupColumn, findColumn, flattenColumnGroup, fromServerDataType, getAllCellsInColumn, getAriaColIndex, getAriaRowIndex, getCalculatedColumnDetails, getColumnLabel, getColumnName, getColumnStyle, getColumnsInViewport, getDefaultAlignment, getDefaultColumnType, getGroupIcon, getGroupValue, getPinStateFromElement, getRuntimeColumnWidth, getServerDataType, getTableHeadings, getTypeFormattingFromColumn, hasCustomRenderer, hasHeadings, hasValidationRules, isCalculatedColumn, isColumnTypeRenderer, isDataLoading, isDateTimeDataType, isDateTimeDataValue, isGroupColumn, isJsonAttribute, isJsonColumn, isJsonGroup, isLookupRenderer, isMappedValueTypeRenderer, isNanoTimestampColumn, isNotHidden, isNumericColumn, isPinned, isResizing, isStringColumn, isTextColumn, isTimeDataType, isTimeDataValue, isTimestampColumn, isTypeDescriptor, isValidColumnAlignment, isValidPinLocation, isValueListRenderer, isVuuColumnDataType, mapSortCriteria, measurePinnedColumns, metadataKeys, moveColumnTo, projectUpdates, removeSort, replaceColumn, setAggregations, setCalculatedColumnExpression, setCalculatedColumnName, setCalculatedColumnType, sortPinnedColumns, subscribedOnly, toColumnDescriptor, toColumnName, toDataSourceColumns, updateColumn, updateColumnFormatting, updateColumnRenderProps, updateColumnType, visibleColumnAtIndex } from './column-utils.js';
9
9
  export { MEASURES } from './common-types.js';
10
10
  export { getCellConfigPanelRenderer, getCellRenderer, getCellRendererOptions, getColumnHeaderContentRenderer, getColumnHeaderLabelRenderer, getConfigurationEditor, getEditRuleValidator, getLayoutComponent, getRegisteredCellRenderers, getRowClassNameGenerator, isContainer, isLayoutComponent, isView, registerComponent, registerConfigurationEditor } from './component-registry.js';
11
11
  export { getCookieValue, setCookieValue } from './cookie-utils.js';
@@ -53,11 +53,11 @@ export { asReactElements, createSyntheticEvent, isSimpleStateValue, useIsMounted
53
53
  export { exceedsMaxSafeInteger, roundDecimal, roundScaledDecimal } from './round-decimal.js';
54
54
  export { actualRowPositioning, asDataSourceRowObject, virtualRowPositioning, vuuRowToDataSourceRow } from './row-utils.js';
55
55
  export { ScaledDecimal, ScaledDecimal2, ScaledDecimal4, ScaledDecimal6, ScaledDecimal8 } from './ScaledDecimal.js';
56
- export { deselectItem, selectItem } from './selection-utils.js';
56
+ export { deselectItem, selectItem, splitSelectableRanges } from './selection-utils.js';
57
57
  export { VuuShellLocation } from './shell-layout-types.js';
58
58
  export { addSortColumn, getSortStatus, setSortColumn, toggleOrApplySort } from './sort-utils.js';
59
59
  export { getVuuTable } from './table-schema-utils.js';
60
- export { lastWord, wordify } from './text-utils.js';
60
+ export { capitalize, lastWord, pluralForm, singularForm, wordify } from './text-utils.js';
61
61
  export { DEFAULT_DENSITY, DEFAULT_THEME, DEFAULT_THEME_MODE, ThemeContext, ThemeProvider, useThemeAttributes } from './ThemeProvider.js';
62
62
  export { dropLastPathSegment, getParentRow, lastPathSegment, missingAncestor, treeToDataSourceRows } from './tree-utils.js';
63
63
  export { elementImplementsJSONSerialization, isNotNullOrUndefined, isObject } from './ts-utils.js';
@@ -26,6 +26,36 @@ const selectItem = (selectionModel, rowKey, rangeSelect, preserveExistingSelecti
26
26
  };
27
27
  }
28
28
  };
29
+ const splitSelectableRanges = (rows, isRowSelectable, preserveExistingSelection) => {
30
+ const requests = [];
31
+ let fromKey;
32
+ let toKey;
33
+ for (const row of rows) {
34
+ if (isRowSelectable(row)) {
35
+ if (!fromKey) fromKey = row.key;
36
+ toKey = row.key;
37
+ } else if (fromKey && toKey) {
38
+ requests.push({
39
+ type: "SELECT_ROW_RANGE",
40
+ fromRowKey: fromKey,
41
+ toRowKey: toKey,
42
+ // first sub-range respects the caller's preserve flag; subsequent ones must preserve
43
+ preserveExistingSelection: requests.length > 0 ? true : preserveExistingSelection
44
+ });
45
+ fromKey = void 0;
46
+ toKey = void 0;
47
+ }
48
+ }
49
+ if (fromKey && toKey) {
50
+ requests.push({
51
+ type: "SELECT_ROW_RANGE",
52
+ fromRowKey: fromKey,
53
+ toRowKey: toKey,
54
+ preserveExistingSelection: requests.length > 0 ? true : preserveExistingSelection
55
+ });
56
+ }
57
+ return requests;
58
+ };
29
59
 
30
- export { deselectItem, selectItem };
60
+ export { deselectItem, selectItem, splitSelectableRanges };
31
61
  //# sourceMappingURL=selection-utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"selection-utils.js","sources":["../../../../../../packages/vuu-utils/src/selection-utils.ts"],"sourcesContent":["import { TableSelectionModel } from \"@vuu-ui/vuu-table-types\";\nimport { SelectRequest } from \"@vuu-ui/vuu-protocol-types\";\n\nexport const deselectItem = (\n selectionModel: TableSelectionModel,\n rowKey: string,\n rangeSelect: boolean,\n preserveExistingSelection = false,\n): Omit<SelectRequest, \"vpId\"> | undefined => {\n return {\n preserveExistingSelection,\n rowKey,\n type: \"DESELECT_ROW\",\n } as Omit<SelectRequest, \"vpId\">;\n};\n\nexport const selectItem = (\n selectionModel: TableSelectionModel,\n rowKey: string,\n rangeSelect: boolean,\n preserveExistingSelection = false,\n activeRowKey?: string,\n): Omit<SelectRequest, \"vpId\"> | undefined => {\n const singleSelect =\n selectionModel === \"single\" || selectionModel === \"single-no-deselect\";\n const actsLikeSingleSelect = singleSelect || activeRowKey === undefined;\n\n if (selectionModel === \"none\") {\n return;\n } else if (actsLikeSingleSelect) {\n const preserveSelection = singleSelect ? false : preserveExistingSelection;\n return {\n preserveExistingSelection: preserveSelection,\n rowKey,\n type: \"SELECT_ROW\",\n } as Omit<SelectRequest, \"vpId\">;\n } else if (rangeSelect) {\n return {\n preserveExistingSelection,\n fromRowKey: rowKey,\n toRowKey: activeRowKey,\n type: \"SELECT_ROW_RANGE\",\n } as Omit<SelectRequest, \"vpId\">;\n }\n};\n"],"names":[],"mappings":"AAGO,MAAM,eAAe,CAC1B,cAAA,EACA,MACA,EAAA,WAAA,EACA,4BAA4B,KACgB,KAAA;AAC5C,EAAO,OAAA;AAAA,IACL,yBAAA;AAAA,IACA,MAAA;AAAA,IACA,IAAM,EAAA;AAAA,GACR;AACF;AAEO,MAAM,aAAa,CACxB,cAAA,EACA,QACA,WACA,EAAA,yBAAA,GAA4B,OAC5B,YAC4C,KAAA;AAC5C,EAAM,MAAA,YAAA,GACJ,cAAmB,KAAA,QAAA,IAAY,cAAmB,KAAA,oBAAA;AACpD,EAAM,MAAA,oBAAA,GAAuB,gBAAgB,YAAiB,KAAA,KAAA,CAAA;AAE9D,EAAA,IAAI,mBAAmB,MAAQ,EAAA;AAC7B,IAAA;AAAA,aACS,oBAAsB,EAAA;AAC/B,IAAM,MAAA,iBAAA,GAAoB,eAAe,KAAQ,GAAA,yBAAA;AACjD,IAAO,OAAA;AAAA,MACL,yBAA2B,EAAA,iBAAA;AAAA,MAC3B,MAAA;AAAA,MACA,IAAM,EAAA;AAAA,KACR;AAAA,aACS,WAAa,EAAA;AACtB,IAAO,OAAA;AAAA,MACL,yBAAA;AAAA,MACA,UAAY,EAAA,MAAA;AAAA,MACZ,QAAU,EAAA,YAAA;AAAA,MACV,IAAM,EAAA;AAAA,KACR;AAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"selection-utils.js","sources":["../../../../../../packages/vuu-utils/src/selection-utils.ts"],"sourcesContent":["import { DataRow, TableSelectionModel } from \"@vuu-ui/vuu-table-types\";\nimport { SelectRequest } from \"@vuu-ui/vuu-protocol-types\";\n\nexport const deselectItem = (\n selectionModel: TableSelectionModel,\n rowKey: string,\n rangeSelect: boolean,\n preserveExistingSelection = false,\n): Omit<SelectRequest, \"vpId\"> | undefined => {\n return {\n preserveExistingSelection,\n rowKey,\n type: \"DESELECT_ROW\",\n } as Omit<SelectRequest, \"vpId\">;\n};\n\nexport const selectItem = (\n selectionModel: TableSelectionModel,\n rowKey: string,\n rangeSelect: boolean,\n preserveExistingSelection = false,\n activeRowKey?: string,\n): Omit<SelectRequest, \"vpId\"> | undefined => {\n const singleSelect =\n selectionModel === \"single\" || selectionModel === \"single-no-deselect\";\n const actsLikeSingleSelect = singleSelect || activeRowKey === undefined;\n\n if (selectionModel === \"none\") {\n return;\n } else if (actsLikeSingleSelect) {\n const preserveSelection = singleSelect ? false : preserveExistingSelection;\n return {\n preserveExistingSelection: preserveSelection,\n rowKey,\n type: \"SELECT_ROW\",\n } as Omit<SelectRequest, \"vpId\">;\n } else if (rangeSelect) {\n return {\n preserveExistingSelection,\n fromRowKey: rowKey,\n toRowKey: activeRowKey,\n type: \"SELECT_ROW_RANGE\",\n } as Omit<SelectRequest, \"vpId\">;\n }\n};\n\n/**\n * Split a row range into sub-ranges that exclude non-selectable rows.\n * Returns one SELECT_ROW_RANGE per consecutive run of selectable rows.\n */\nexport const splitSelectableRanges = (\n rows: DataRow[],\n isRowSelectable: (row: DataRow) => boolean,\n preserveExistingSelection: boolean,\n): Omit<SelectRequest, \"vpId\">[] => {\n const requests: Omit<SelectRequest, \"vpId\">[] = [];\n let fromKey: string | undefined;\n let toKey: string | undefined;\n\n for (const row of rows) {\n if (isRowSelectable(row)) {\n if (!fromKey) fromKey = row.key;\n toKey = row.key;\n } else if (fromKey && toKey) {\n requests.push({\n type: \"SELECT_ROW_RANGE\",\n fromRowKey: fromKey,\n toRowKey: toKey,\n // first sub-range respects the caller's preserve flag; subsequent ones must preserve\n preserveExistingSelection: requests.length > 0 ? true : preserveExistingSelection,\n } as Omit<SelectRequest, \"vpId\">);\n fromKey = undefined;\n toKey = undefined;\n }\n }\n if (fromKey && toKey) {\n requests.push({\n type: \"SELECT_ROW_RANGE\",\n fromRowKey: fromKey,\n toRowKey: toKey,\n preserveExistingSelection: requests.length > 0 ? true : preserveExistingSelection,\n } as Omit<SelectRequest, \"vpId\">);\n }\n return requests;\n};\n"],"names":[],"mappings":"AAGO,MAAM,eAAe,CAC1B,cAAA,EACA,MACA,EAAA,WAAA,EACA,4BAA4B,KACgB,KAAA;AAC5C,EAAO,OAAA;AAAA,IACL,yBAAA;AAAA,IACA,MAAA;AAAA,IACA,IAAM,EAAA;AAAA,GACR;AACF;AAEO,MAAM,aAAa,CACxB,cAAA,EACA,QACA,WACA,EAAA,yBAAA,GAA4B,OAC5B,YAC4C,KAAA;AAC5C,EAAM,MAAA,YAAA,GACJ,cAAmB,KAAA,QAAA,IAAY,cAAmB,KAAA,oBAAA;AACpD,EAAM,MAAA,oBAAA,GAAuB,gBAAgB,YAAiB,KAAA,KAAA,CAAA;AAE9D,EAAA,IAAI,mBAAmB,MAAQ,EAAA;AAC7B,IAAA;AAAA,aACS,oBAAsB,EAAA;AAC/B,IAAM,MAAA,iBAAA,GAAoB,eAAe,KAAQ,GAAA,yBAAA;AACjD,IAAO,OAAA;AAAA,MACL,yBAA2B,EAAA,iBAAA;AAAA,MAC3B,MAAA;AAAA,MACA,IAAM,EAAA;AAAA,KACR;AAAA,aACS,WAAa,EAAA;AACtB,IAAO,OAAA;AAAA,MACL,yBAAA;AAAA,MACA,UAAY,EAAA,MAAA;AAAA,MACZ,QAAU,EAAA,YAAA;AAAA,MACV,IAAM,EAAA;AAAA,KACR;AAAA;AAEJ;AAMO,MAAM,qBAAwB,GAAA,CACnC,IACA,EAAA,eAAA,EACA,yBACkC,KAAA;AAClC,EAAA,MAAM,WAA0C,EAAC;AACjD,EAAI,IAAA,OAAA;AACJ,EAAI,IAAA,KAAA;AAEJ,EAAA,KAAA,MAAW,OAAO,IAAM,EAAA;AACtB,IAAI,IAAA,eAAA,CAAgB,GAAG,CAAG,EAAA;AACxB,MAAI,IAAA,CAAC,OAAS,EAAA,OAAA,GAAU,GAAI,CAAA,GAAA;AAC5B,MAAA,KAAA,GAAQ,GAAI,CAAA,GAAA;AAAA,KACd,MAAA,IAAW,WAAW,KAAO,EAAA;AAC3B,MAAA,QAAA,CAAS,IAAK,CAAA;AAAA,QACZ,IAAM,EAAA,kBAAA;AAAA,QACN,UAAY,EAAA,OAAA;AAAA,QACZ,QAAU,EAAA,KAAA;AAAA;AAAA,QAEV,yBAA2B,EAAA,QAAA,CAAS,MAAS,GAAA,CAAA,GAAI,IAAO,GAAA;AAAA,OAC1B,CAAA;AAChC,MAAU,OAAA,GAAA,KAAA,CAAA;AACV,MAAQ,KAAA,GAAA,KAAA,CAAA;AAAA;AACV;AAEF,EAAA,IAAI,WAAW,KAAO,EAAA;AACpB,IAAA,QAAA,CAAS,IAAK,CAAA;AAAA,MACZ,IAAM,EAAA,kBAAA;AAAA,MACN,UAAY,EAAA,OAAA;AAAA,MACZ,QAAU,EAAA,KAAA;AAAA,MACV,yBAA2B,EAAA,QAAA,CAAS,MAAS,GAAA,CAAA,GAAI,IAAO,GAAA;AAAA,KAC1B,CAAA;AAAA;AAElC,EAAO,OAAA,QAAA;AACT;;;;"}
@@ -8,11 +8,13 @@ const lastWord = (text) => {
8
8
  }
9
9
  };
10
10
  const capitalize = (text) => text.length === 0 ? "" : text[0].toUpperCase() + text.slice(1);
11
+ const singularForm = (typeName) => typeof typeName === "string" ? typeName : typeName.singular;
12
+ const pluralForm = (typeName) => typeof typeName === "string" ? `${typeName}s` : typeName.plural;
11
13
  const regexp_worfify = /(?<!(^|[A-Z]))(?=[A-Z])|(?<!^)(?=[A-Z][a-z])/;
12
14
  const wordify = (text) => {
13
15
  const [firstWord, ...rest] = text.split(regexp_worfify);
14
16
  return `${capitalize(firstWord)} ${rest.join(" ")}`;
15
17
  };
16
18
 
17
- export { lastWord, wordify };
19
+ export { capitalize, lastWord, pluralForm, singularForm, wordify };
18
20
  //# sourceMappingURL=text-utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"text-utils.js","sources":["../../../../../../packages/vuu-utils/src/text-utils.ts"],"sourcesContent":["export const lastWord = (text: string): string => {\n const trimmedText = text.trim();\n const pos = trimmedText.lastIndexOf(\" \");\n if (pos === -1) {\n return trimmedText;\n } else {\n return trimmedText.slice(pos + 1);\n }\n};\n\nconst capitalize = (text: string) =>\n text.length === 0 ? \"\" : text[0].toUpperCase() + text.slice(1);\n\nconst regexp_worfify = /(?<!(^|[A-Z]))(?=[A-Z])|(?<!^)(?=[A-Z][a-z])/;\nexport const wordify = (text: string) => {\n const [firstWord, ...rest] = text.split(regexp_worfify);\n return `${capitalize(firstWord)} ${rest.join(\" \")}`;\n};\n"],"names":[],"mappings":"AAAa,MAAA,QAAA,GAAW,CAAC,IAAyB,KAAA;AAChD,EAAM,MAAA,WAAA,GAAc,KAAK,IAAK,EAAA;AAC9B,EAAM,MAAA,GAAA,GAAM,WAAY,CAAA,WAAA,CAAY,GAAG,CAAA;AACvC,EAAA,IAAI,QAAQ,CAAI,CAAA,EAAA;AACd,IAAO,OAAA,WAAA;AAAA,GACF,MAAA;AACL,IAAO,OAAA,WAAA,CAAY,KAAM,CAAA,GAAA,GAAM,CAAC,CAAA;AAAA;AAEpC;AAEA,MAAM,UAAa,GAAA,CAAC,IAClB,KAAA,IAAA,CAAK,WAAW,CAAI,GAAA,EAAA,GAAK,IAAK,CAAA,CAAC,CAAE,CAAA,WAAA,EAAgB,GAAA,IAAA,CAAK,MAAM,CAAC,CAAA;AAE/D,MAAM,cAAiB,GAAA,8CAAA;AACV,MAAA,OAAA,GAAU,CAAC,IAAiB,KAAA;AACvC,EAAA,MAAM,CAAC,SAAW,EAAA,GAAG,IAAI,CAAI,GAAA,IAAA,CAAK,MAAM,cAAc,CAAA;AACtD,EAAO,OAAA,CAAA,EAAG,WAAW,SAAS,CAAC,IAAI,IAAK,CAAA,IAAA,CAAK,GAAG,CAAC,CAAA,CAAA;AACnD;;;;"}
1
+ {"version":3,"file":"text-utils.js","sources":["../../../../../../packages/vuu-utils/src/text-utils.ts"],"sourcesContent":["export type SingularPluralForm = {\n singular: string;\n plural: string;\n};\n\nexport type ItemTypeName = string | SingularPluralForm;\n\nexport const lastWord = (text: string): string => {\n const trimmedText = text.trim();\n const pos = trimmedText.lastIndexOf(\" \");\n if (pos === -1) {\n return trimmedText;\n } else {\n return trimmedText.slice(pos + 1);\n }\n};\n\nexport const capitalize = (text: string) =>\n text.length === 0 ? \"\" : text[0].toUpperCase() + text.slice(1);\n\nexport const singularForm = (typeName: ItemTypeName) =>\n typeof typeName === \"string\" ? typeName : typeName.singular;\n\nexport const pluralForm = (typeName: ItemTypeName) =>\n typeof typeName === \"string\" ? `${typeName}s` : typeName.plural;\n\nconst regexp_worfify = /(?<!(^|[A-Z]))(?=[A-Z])|(?<!^)(?=[A-Z][a-z])/;\nexport const wordify = (text: string) => {\n const [firstWord, ...rest] = text.split(regexp_worfify);\n return `${capitalize(firstWord)} ${rest.join(\" \")}`;\n};\n"],"names":[],"mappings":"AAOa,MAAA,QAAA,GAAW,CAAC,IAAyB,KAAA;AAChD,EAAM,MAAA,WAAA,GAAc,KAAK,IAAK,EAAA;AAC9B,EAAM,MAAA,GAAA,GAAM,WAAY,CAAA,WAAA,CAAY,GAAG,CAAA;AACvC,EAAA,IAAI,QAAQ,CAAI,CAAA,EAAA;AACd,IAAO,OAAA,WAAA;AAAA,GACF,MAAA;AACL,IAAO,OAAA,WAAA,CAAY,KAAM,CAAA,GAAA,GAAM,CAAC,CAAA;AAAA;AAEpC;AAEO,MAAM,UAAa,GAAA,CAAC,IACzB,KAAA,IAAA,CAAK,WAAW,CAAI,GAAA,EAAA,GAAK,IAAK,CAAA,CAAC,CAAE,CAAA,WAAA,EAAgB,GAAA,IAAA,CAAK,MAAM,CAAC;AAExD,MAAM,eAAe,CAAC,QAAA,KAC3B,OAAO,QAAa,KAAA,QAAA,GAAW,WAAW,QAAS,CAAA;AAExC,MAAA,UAAA,GAAa,CAAC,QACzB,KAAA,OAAO,aAAa,QAAW,GAAA,CAAA,EAAG,QAAQ,CAAA,CAAA,CAAA,GAAM,QAAS,CAAA;AAE3D,MAAM,cAAiB,GAAA,8CAAA;AACV,MAAA,OAAA,GAAU,CAAC,IAAiB,KAAA;AACvC,EAAA,MAAM,CAAC,SAAW,EAAA,GAAG,IAAI,CAAI,GAAA,IAAA,CAAK,MAAM,cAAc,CAAA;AACtD,EAAO,OAAA,CAAA,EAAG,WAAW,SAAS,CAAC,IAAI,IAAK,CAAA,IAAA,CAAK,GAAG,CAAC,CAAA,CAAA;AACnD;;;;"}
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.2.0",
2
+ "version": "2.3.0",
3
3
  "author": "heswell",
4
4
  "license": "Apache-2.0",
5
5
  "types": "types/index.d.ts",
@@ -7,14 +7,14 @@
7
7
  "@salt-ds/core": "1.54.1"
8
8
  },
9
9
  "devDependencies": {
10
- "@vuu-ui/vuu-data-types": "2.2.0",
11
- "@vuu-ui/vuu-table-types": "2.2.0",
12
- "@vuu-ui/vuu-filter-types": "2.2.0",
13
- "@vuu-ui/vuu-protocol-types": "2.2.0"
10
+ "@vuu-ui/vuu-data-types": "2.3.0",
11
+ "@vuu-ui/vuu-table-types": "2.3.0",
12
+ "@vuu-ui/vuu-filter-types": "2.3.0",
13
+ "@vuu-ui/vuu-protocol-types": "2.3.0"
14
14
  },
15
15
  "peerDependencies": {
16
16
  "@internationalized/date": "^3.0.0",
17
- "@vuu-ui/vuu-filter-parser": "2.2.0",
17
+ "@vuu-ui/vuu-filter-parser": "2.3.0",
18
18
  "clsx": "^2.0.0",
19
19
  "react": "^19.2.3",
20
20
  "react-dom": "^19.2.3"
@@ -6,3 +6,11 @@ export declare const moveItemDeprecated: <T = unknown>(items: T[], item: T, move
6
6
  export declare const moveItem: <T = unknown>(items: T[], fromIndex: number, toIndex: number) => T[];
7
7
  export declare const getAddedItems: <T>(values: undefined | T[], newValues: T[]) => T[];
8
8
  export declare const getMissingItems: <T, I>(sourceItems: T[], items: I[], identity: (s: T) => I) => I[];
9
+ /**
10
+ * Given an ordered list of item names, return items in same order
11
+ */
12
+ export declare const reorderItems: <T extends {
13
+ name: string;
14
+ } = {
15
+ name: string;
16
+ }>(originalItems: readonly T[], orderedNames: string[]) => T[];
@@ -1,8 +1,8 @@
1
1
  import type { DataSourceRow, DataValueDescriptor, DataValueType, DataValueTypeSimple, DateTimeDataValueDescriptor, SchemaColumn, TableSchema, TimeDataValueDescriptor } from "@vuu-ui/vuu-data-types";
2
2
  import type { VuuAggType, VuuAggregation, VuuColumnDataType, VuuDataRowDto, VuuGroupBy, VuuSort } from "@vuu-ui/vuu-protocol-types";
3
- import type { ColumnAlignment, ColumnDescriptor, ColumnLayout, DataValueTypeDescriptor, ColumnTypeFormatting, ColumnTypeRendering, ColumnTypeWithValidationRules, DefaultColumnConfiguration, GroupColumnDescriptor, LookupRenderer, MappedValueTypeRenderer, PinLocation, RuntimeColumnDescriptor, TableCellRendererProps, TableConfig, TableHeadings, ValueListRenderer, DataRow } from "@vuu-ui/vuu-table-types";
4
- import { type CSSProperties } from "react";
5
3
  import { TableModel } from "@vuu-ui/vuu-table";
4
+ import type { ColumnAlignment, ColumnDescriptor, ColumnLayout, ColumnTypeFormatting, ColumnTypeRendering, ColumnTypeWithValidationRules, DataRow, DataValueTypeDescriptor, DefaultColumnConfiguration, GroupColumnDescriptor, LookupRenderer, MappedValueTypeRenderer, PinLocation, RuntimeColumnDescriptor, TableCellRendererProps, TableConfig, TableHeadings, ValueListRenderer } from "@vuu-ui/vuu-table-types";
5
+ import { type CSSProperties } from "react";
6
6
  /**
7
7
  * ColumnMap provides a lookup of the index position of a data item within a row
8
8
  * by column name.
@@ -205,13 +205,5 @@ export declare const dataAndColumnUnchanged: (p: TableCellRendererProps, p1: Tab
205
205
  export declare const dataColumnAndKeyUnchanged: (p: TableCellRendererProps, p1: TableCellRendererProps) => boolean;
206
206
  export declare const toColumnName: (column: ColumnDescriptor) => string;
207
207
  export declare const isStringColumn: (column: ColumnDescriptor) => boolean;
208
- /**
209
- * Given an ordered list of column names, return column items in same order
210
- */
211
- export declare const reorderColumnItems: <T extends {
212
- name: string;
213
- } = {
214
- name: string;
215
- }>(columnItems: readonly T[], orderedNames: string[]) => T[];
216
208
  export declare const columnByAriaIndex: (columns: RuntimeColumnDescriptor[], ariaColIndex: number) => RuntimeColumnDescriptor;
217
209
  export {};
@@ -25,8 +25,8 @@ export declare const stripFilterFromColumns: (columns: RuntimeColumnDescriptor[]
25
25
  align?: "left" | "right";
26
26
  ariaColIndex: number;
27
27
  CellRenderer?: import("react").FunctionComponent<import("@vuu-ui/vuu-table-types").TableCellRendererProps>;
28
- HeaderCellLabelRenderer?: import("react").FunctionComponent<Omit<import("@vuu-ui/vuu-table-types").HeaderCellProps, "id" | "index">>;
29
28
  HeaderCellContentRenderer?: import("react").FunctionComponent<Omit<import("@vuu-ui/vuu-table-types").HeaderCellProps, "id" | "index">>;
29
+ HeaderCellLabelRenderer?: import("react").FunctionComponent<Omit<import("@vuu-ui/vuu-table-types").HeaderCellProps, "id" | "index">>;
30
30
  canStretch?: boolean;
31
31
  className?: string;
32
32
  clientSideEditValidationCheck?: import("@vuu-ui/vuu-data-types").DataValueValidationChecker;
@@ -1,4 +1,9 @@
1
- import { TableSelectionModel } from "@vuu-ui/vuu-table-types";
1
+ import { DataRow, TableSelectionModel } from "@vuu-ui/vuu-table-types";
2
2
  import { SelectRequest } from "@vuu-ui/vuu-protocol-types";
3
3
  export declare const deselectItem: (selectionModel: TableSelectionModel, rowKey: string, rangeSelect: boolean, preserveExistingSelection?: boolean) => Omit<SelectRequest, "vpId"> | undefined;
4
4
  export declare const selectItem: (selectionModel: TableSelectionModel, rowKey: string, rangeSelect: boolean, preserveExistingSelection?: boolean, activeRowKey?: string) => Omit<SelectRequest, "vpId"> | undefined;
5
+ /**
6
+ * Split a row range into sub-ranges that exclude non-selectable rows.
7
+ * Returns one SELECT_ROW_RANGE per consecutive run of selectable rows.
8
+ */
9
+ export declare const splitSelectableRanges: (rows: DataRow[], isRowSelectable: (row: DataRow) => boolean, preserveExistingSelection: boolean) => Omit<SelectRequest, "vpId">[];
@@ -1,2 +1,10 @@
1
+ export type SingularPluralForm = {
2
+ singular: string;
3
+ plural: string;
4
+ };
5
+ export type ItemTypeName = string | SingularPluralForm;
1
6
  export declare const lastWord: (text: string) => string;
7
+ export declare const capitalize: (text: string) => string;
8
+ export declare const singularForm: (typeName: ItemTypeName) => string;
9
+ export declare const pluralForm: (typeName: ItemTypeName) => string;
2
10
  export declare const wordify: (text: string) => string;