ag-common 0.0.258 → 0.0.261

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,5 +1,5 @@
1
1
  import { ISearchDialog, TSearchModalRes } from './types';
2
- export declare const SearchBase: <T>({ onSelectItem, onSearchTextChange, placeholderText, closeText, renderItem, displayItems, willDisplayItem, getKeyF, className, }: ISearchDialog<T> & {
2
+ export declare const SearchBase: <T>({ onSelectItem, onSearchTextChange, placeholderText, closeText, renderItem, displayItems, willDisplayItem, getKeyF, className, texts, }: ISearchDialog<T> & {
3
3
  onSearchTextChange?: ((v: string) => void) | undefined;
4
4
  onSelectItem?: ((v: TSearchModalRes<T>) => void) | undefined;
5
5
  }) => JSX.Element;
@@ -94,13 +94,9 @@ const Content = styled_components_1.default.div `
94
94
  `;
95
95
  const Row = styled_components_1.default.div `
96
96
  width: 100%;
97
- height: 100%;
98
- display: flex;
99
- flex-flow: column;
100
- justify-content: center;
101
- align-items: center;
102
97
  `;
103
- const SearchBase = ({ onSelectItem, onSearchTextChange, placeholderText, closeText, renderItem, displayItems, willDisplayItem, getKeyF, className, }) => {
98
+ const SearchBase = ({ onSelectItem, onSearchTextChange, placeholderText, closeText, renderItem, displayItems, willDisplayItem, getKeyF, className, texts, }) => {
99
+ var _a, _b;
104
100
  const [searchText, setSearchText] = (0, react_1.useState)('');
105
101
  const resWrap = (foundItem) => {
106
102
  if (!foundItem) {
@@ -111,6 +107,8 @@ const SearchBase = ({ onSelectItem, onSearchTextChange, placeholderText, closeTe
111
107
  }
112
108
  };
113
109
  const filteredItems = displayItems.filter((i) => willDisplayItem(searchText, i));
110
+ const showText = (_b = (_a = texts === null || texts === void 0 ? void 0 : texts.totalItems) === null || _a === void 0 ? void 0 : _a.call(texts, filteredItems.length, displayItems.length)) !== null && _b !== void 0 ? _b : `Showing ${filteredItems.length} out of ${displayItems.length} total
111
+ items`;
114
112
  return (react_1.default.createElement(Base, { className: className },
115
113
  react_1.default.createElement(SearchBox, { "data-type": "search" },
116
114
  react_1.default.createElement(TextEdit_1.TextEdit, { placeholder: placeholderText, defaultValue: "", onSubmit: (v) => (0, helpers_1.debounce)(() => {
@@ -118,6 +116,8 @@ const SearchBase = ({ onSelectItem, onSearchTextChange, placeholderText, closeTe
118
116
  onSearchTextChange === null || onSearchTextChange === void 0 ? void 0 : onSearchTextChange(v);
119
117
  }, { key: 'pagesearch', time: 200 }), defaultEditing: { focus: true }, singleLine: true, leftContent: react_1.default.createElement(Icon, null, MagnifyIconSvg), noGrow: true, allowUndo: false, onEscape: () => resWrap(undefined), onClickOutsideWithNoValue: null }),
120
118
  react_1.default.createElement(CloseButton, { onClick: () => resWrap(undefined) }, closeText)),
121
- react_1.default.createElement(Content, { "data-hasitems": !!filteredItems.length, "data-type": "content" }, filteredItems.map((i, index) => (react_1.default.createElement(Row, { key: getKeyF(i), onClick: () => resWrap(i) }, renderItem(searchText, i, index)))))));
119
+ react_1.default.createElement(Content, { "data-hasitems": !!filteredItems.length, "data-type": "content" },
120
+ filteredItems.map((i, index) => (react_1.default.createElement(Row, { key: getKeyF(i), onClick: () => resWrap(i) }, renderItem(searchText, i, index)))),
121
+ searchText && react_1.default.createElement(Row, null, showText))));
122
122
  };
123
123
  exports.SearchBase = SearchBase;
@@ -18,6 +18,12 @@ export interface ISearchDialog<T> {
18
18
  */
19
19
  getKeyF: (i: T) => string;
20
20
  className?: string;
21
+ texts?: {
22
+ /**
23
+ * default if not provided: "showing X out of Y total items"
24
+ */
25
+ totalItems?: (showing: number, outof: number) => string;
26
+ };
21
27
  }
22
28
  export declare type TSearchModalRes<T> = undefined | {
23
29
  foundItem: T;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ag-common",
3
- "version": "0.0.258",
3
+ "version": "0.0.261",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "author": "Andrei Gec <@andreigec> (https://gec.dev/)",
@@ -22,40 +22,40 @@
22
22
  "jsonwebtoken": "8.x",
23
23
  "jwks-rsa": "2.x",
24
24
  "node-cache": "5.x",
25
- "openapi-request-validator": "11.0.1",
26
- "react": "18.1.0",
27
- "react-dom": "18.1.0",
25
+ "openapi-request-validator": "11.1.0",
26
+ "react": "18.2.0",
27
+ "react-dom": "18.2.0",
28
28
  "react-hot-toast": "2.x",
29
29
  "styled-components": "5.x",
30
30
  "typescript": "4.x"
31
31
  },
32
32
  "devDependencies": {
33
- "@babel/core": "7.18.2",
34
- "@storybook/addon-actions": "6.5.6",
35
- "@storybook/addon-docs": "6.5.6",
36
- "@storybook/addon-essentials": "6.5.6",
37
- "@storybook/addon-interactions": "6.5.6",
38
- "@storybook/addon-links": "6.5.6",
39
- "@storybook/addons": "6.5.6",
40
- "@storybook/react": "6.5.6",
41
- "@storybook/theming": "6.5.6",
33
+ "@babel/core": "7.18.5",
34
+ "@storybook/addon-actions": "6.5.9",
35
+ "@storybook/addon-docs": "6.5.9",
36
+ "@storybook/addon-essentials": "6.5.9",
37
+ "@storybook/addon-interactions": "6.5.9",
38
+ "@storybook/addon-links": "6.5.9",
39
+ "@storybook/addons": "6.5.9",
40
+ "@storybook/react": "6.5.9",
41
+ "@storybook/theming": "6.5.9",
42
42
  "@types/jsonwebtoken": "8.5.8",
43
- "@types/node": "17.0.38",
43
+ "@types/node": "17.0.45",
44
44
  "@types/react": "17.0.43",
45
45
  "@types/react-dom": "17.0.14",
46
46
  "@types/styled-components": "5.1.25",
47
- "@typescript-eslint/eslint-plugin": "5.27.0",
48
- "@typescript-eslint/parser": "5.27.0",
47
+ "@typescript-eslint/eslint-plugin": "5.28.0",
48
+ "@typescript-eslint/parser": "5.28.0",
49
49
  "cross-env": "7.0.3",
50
- "eslint": "8.16.0",
50
+ "eslint": "8.17.0",
51
51
  "eslint-config-airbnb-typescript": "17.0.0",
52
52
  "eslint-config-prettier": "8.5.0",
53
53
  "eslint-plugin-import": "2.26.0",
54
54
  "eslint-plugin-jsx-a11y": "6.5.1",
55
55
  "eslint-plugin-prettier": "4.0.0",
56
56
  "eslint-plugin-react": "7.30.0",
57
- "eslint-plugin-react-hooks": "4.5.0",
58
- "prettier": "2.6.2",
57
+ "eslint-plugin-react-hooks": "4.6.0",
58
+ "prettier": "2.7.1",
59
59
  "rimraf": "3.0.2"
60
60
  },
61
61
  "files": [