ag-common 0.0.252 → 0.0.255

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 (46) hide show
  1. package/dist/api/helpers/api.d.ts +1 -1
  2. package/dist/api/helpers/openApiHelpers.js +1 -1
  3. package/dist/common/helpers/date.d.ts +1 -1
  4. package/dist/ui/components/Chevron/index.d.ts +0 -1
  5. package/dist/ui/components/Confirm/Modal.d.ts +0 -1
  6. package/dist/ui/components/DropdownList/index.d.ts +0 -1
  7. package/dist/ui/components/DropdownList/types.d.ts +0 -1
  8. package/dist/ui/components/HeadersRaw/index.d.ts +0 -1
  9. package/dist/ui/components/KebabDots/index.d.ts +0 -1
  10. package/dist/ui/components/Loader/index.d.ts +0 -1
  11. package/dist/ui/components/LoginButton/index.d.ts +0 -1
  12. package/dist/ui/components/LogoutButton/index.d.ts +0 -1
  13. package/dist/ui/components/Modal/index.d.ts +0 -1
  14. package/dist/ui/components/OpenApiCodeBlock/OpenApiCodeBlock.d.ts +0 -1
  15. package/dist/ui/components/OpenApiCodeBlock/curl/helpers/body.d.ts +0 -1
  16. package/dist/ui/components/OpenApiCodeBlock/curl/helpers/security.d.ts +0 -1
  17. package/dist/ui/components/OpenApiCodeBlock/curl/index.d.ts +0 -1
  18. package/dist/ui/components/OpenApiCodeBlock/fetch/helpers/call.d.ts +0 -1
  19. package/dist/ui/components/OpenApiCodeBlock/fetch/helpers/req.d.ts +0 -1
  20. package/dist/ui/components/OpenApiCodeBlock/fetch/index.d.ts +0 -1
  21. package/dist/ui/components/OpenApiCodeBlock/helpers/joinJsx.d.ts +0 -1
  22. package/dist/ui/components/OpenApiCodeBlock/types.d.ts +0 -1
  23. package/dist/ui/components/Prompt/Modal.d.ts +0 -1
  24. package/dist/ui/components/Search/Base.d.ts +0 -1
  25. package/dist/ui/components/Search/Inline.d.ts +0 -1
  26. package/dist/ui/components/Search/Modal.d.ts +0 -1
  27. package/dist/ui/components/Search/types.d.ts +0 -1
  28. package/dist/ui/components/Sidebar/index.d.ts +0 -1
  29. package/dist/ui/components/SparkLine/index.d.ts +0 -1
  30. package/dist/ui/components/Table/index.d.ts +0 -1
  31. package/dist/ui/components/TextEdit/CheckboxEdit.d.ts +0 -1
  32. package/dist/ui/components/TextEdit/ColourEdit.d.ts +0 -1
  33. package/dist/ui/components/TextEdit/LengthBox.d.ts +0 -1
  34. package/dist/ui/components/TextEdit/ListboxEdit.d.ts +8 -5
  35. package/dist/ui/components/TextEdit/ListboxEdit.js +12 -2
  36. package/dist/ui/components/TextEdit/RadioGroup.d.ts +0 -1
  37. package/dist/ui/components/TextEdit/RadioGroup.js +7 -4
  38. package/dist/ui/components/TextEdit/TextEdit.d.ts +0 -1
  39. package/dist/ui/components/TextEdit/TextEdit.js +1 -1
  40. package/dist/ui/components/TextEdit/images.d.ts +0 -1
  41. package/dist/ui/components/Toast/index.d.ts +1 -2
  42. package/dist/ui/components/UserImage/index.d.ts +0 -1
  43. package/dist/ui/helpers/date.d.ts +1 -1
  44. package/dist/ui/helpers/jwt.d.ts +2 -2
  45. package/dist/ui/helpers/useLocalStorage.d.ts +3 -3
  46. package/package.json +13 -13
@@ -1,7 +1,7 @@
1
1
  import { APIGatewayProxyResult, DYNAMOKEYS } from '../types';
2
2
  export declare const returnCode: <T>(statusCode: number, body?: T | undefined, extraHeaders?: {
3
3
  [a: string]: string;
4
- } | undefined, fullSiteUrl?: string | undefined) => APIGatewayProxyResult;
4
+ } | undefined, fullSiteUrl?: string) => APIGatewayProxyResult;
5
5
  /**
6
6
  * strip all dynamo generated keys. can optionally keep PK
7
7
  * @param record
@@ -136,7 +136,7 @@ const openApiImpl = (p) => {
136
136
  const entry = `${endpointsBase}${fullPath}/${verb.toUpperCase()}.ts`;
137
137
  const lambdaV = new aws_cdk_lib_1.aws_lambda_nodejs.NodejsFunction(stack, lambdaName, {
138
138
  functionName: lambdaName,
139
- runtime: aws_cdk_lib_1.aws_lambda.Runtime.NODEJS_14_X,
139
+ runtime: aws_cdk_lib_1.aws_lambda.Runtime.NODEJS_16_X,
140
140
  handler: 'handler',
141
141
  environment: lc.environment,
142
142
  memorySize: lc.memory,
@@ -11,4 +11,4 @@ export declare const CSharpToJs: (charpTicks: number) => Date;
11
11
  * @param date default = now
12
12
  * @returns
13
13
  */
14
- export declare const dateTimeToNearestMinute: (minutes: number, date?: Date | undefined) => Date;
14
+ export declare const dateTimeToNearestMinute: (minutes: number, date?: Date) => Date;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const Chevron: ({ width, className, colour, onToggle, point, }: {
3
2
  /**
4
3
  * default right
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const ConfirmModal: ({ onSubmit, bottomText, topText, okText, cancelText, }: {
3
2
  onSubmit: (v: boolean) => void;
4
3
  topText?: string | undefined;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import { IDropdownList } from './types';
3
2
  export declare function DropdownList<T>(p: IDropdownList<T>): JSX.Element;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export interface IDropdownList<T> {
3
2
  /**
4
3
  * all items that can be in dropdown
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export interface IHeadersRaw {
3
2
  title?: string;
4
3
  image?: string;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const KebabDots: ({ onClick }: {
3
2
  onClick?: (() => Promise<void>) | undefined;
4
3
  }) => JSX.Element;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const Loader: ({ name, height, width, }: {
3
2
  /**
4
3
  * default 2rem
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const LoginButton: ({ className, text, invert, savePath, loginPath, style, }: {
3
2
  invert?: boolean | undefined;
4
3
  text: string;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const LogoutButton: ({ className, invert, logout, }: {
3
2
  invert?: boolean | undefined;
4
3
  className?: string | undefined;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const ModalItem: import("styled-components").StyledComponent<"div", any, {}, never>;
3
2
  export declare const Modal: ({ open, setOpen, children, position, topPosition, showCloseButton, closeOnMoveMouseOutside, className, closeOnClickOutside, }: {
4
3
  open: boolean;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import { IOpenApiCodeBlock } from './types';
3
2
  export declare const OpenApiCodeBlock: <TDefaultApi>(p: IOpenApiCodeBlock<TDefaultApi>) => JSX.Element;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { IOpenApiCodeBlock } from '../../types';
3
2
  export declare const getBody: <TDefaultApi>(p: IOpenApiCodeBlock<TDefaultApi>) => {
4
3
  content: JSX.Element | undefined;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { IOpenApi, IOpenApiOperation } from '../../types';
3
2
  export declare const getSecurityLine: (p: {
4
3
  apiKey?: string;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { IOpenApiCodeBlock, IOpenApiOperationBlock } from '../types';
3
2
  export declare const Curl: <TDefaultApi>({ ops, p, }: {
4
3
  p: IOpenApiCodeBlock<TDefaultApi>;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import { IOpenApiCodeBlock, IOpenApiOperationBlock } from '../../types';
3
2
  export declare const getFetchCall: <TDefaultApi>(p: IOpenApiCodeBlock<TDefaultApi>, ops: IOpenApiOperationBlock) => JSX.Element | undefined;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import { IOpenApiCodeBlock, IOpenApiOperationBlock } from '../../types';
3
2
  export declare const getRequestOptions: <TDefaultApi>(p: IOpenApiCodeBlock<TDefaultApi>, ops: IOpenApiOperationBlock) => JSX.Element | undefined;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { IOpenApiCodeBlock, IOpenApiOperationBlock } from '../types';
3
2
  export declare const Fetch: <TDefaultApi>({ ops, p, }: {
4
3
  p: IOpenApiCodeBlock<TDefaultApi>;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const joinJsx: (items: (JSX.Element | undefined)[], sep: JSX.Element[]) => JSX.Element[];
3
2
  export declare const joinJsxWithSlash: (items: (JSX.Element | undefined)[]) => JSX.Element[];
4
3
  export declare const joinJsxWithComma: (items: (JSX.Element | undefined)[]) => JSX.Element[];
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export interface IOpenApiOperation {
3
2
  description: string;
4
3
  operationId: string;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const PromptModal: ({ wrapper, res, bottomText, topText, okText, cancelText, defaultValue, placeholder, }: {
3
2
  defaultValue?: string | undefined;
4
3
  placeholder?: string | undefined;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { ISearchDialog, TSearchModalRes } from './types';
3
2
  export declare const SearchBase: <T>({ onSelectItem, onSearchTextChange, placeholderText, closeText, renderItem, displayItems, willDisplayItem, getKeyF, }: ISearchDialog<T> & {
4
3
  onSearchTextChange?: ((v: string) => void) | undefined;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { ISearchDialog, TSearchModalRes } from './types';
3
2
  export declare const SearchInline: <T>(p: ISearchDialog<T> & {
4
3
  onSelectItem?: ((v: TSearchModalRes<T>) => void) | undefined;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { ISearchDialog, TSearchModalRes } from './types';
3
2
  export declare const SearchModal: <T>(p: ISearchDialog<T> & {
4
3
  onSelectItem: (v: TSearchModalRes<T>) => void;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export interface ISearchDialog<T> {
3
2
  placeholderText?: string;
4
3
  closeText?: string;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const Sidebar: ({ children, className, key, cookieDocument, width, }: {
3
2
  children: any;
4
3
  className?: string | undefined;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export interface ISparkLine {
3
2
  /**
4
3
  * default #4d76ff
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export interface TableItem {
3
2
  content: JSX.Element;
4
3
  groupTitle: string;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const CheckboxEdit: ({ defaultValue, onSubmit, noGrow, }: {
3
2
  defaultValue: boolean;
4
3
  onSubmit: (val: boolean) => void;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const ColourEdit: ({ defaultValue, onSubmit, }: {
3
2
  defaultValue: string;
4
3
  onSubmit: (val: string) => void;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const TextEditLengthBox: ({ min, max, }: {
3
2
  min: number;
4
3
  max: number;
@@ -1,10 +1,13 @@
1
- /// <reference types="react" />
2
- export declare const ListboxEdit: ({ defaultValue, onSubmit, values, canEdit, }: {
3
- defaultValue: string;
4
- onSubmit: (val: string) => void;
5
- values: string[];
1
+ export declare const ListboxEdit: <T>({ defaultValue, onSubmit, values, canEdit, renderLabel, }: {
2
+ defaultValue: T;
3
+ onSubmit: (val: T) => void;
4
+ values: T[];
6
5
  /**
7
6
  * if true can revert or explicit save. default true
8
7
  */
9
8
  canEdit?: boolean | undefined;
9
+ /**
10
+ * can overload the render of the label. defaults to toString
11
+ */
12
+ renderLabel?: ((a: T) => string) | undefined;
10
13
  }) => JSX.Element;
@@ -28,13 +28,23 @@ const images_1 = require("./images");
28
28
  const common_1 = require("./common");
29
29
  const common_2 = require("../../styles/common");
30
30
  const react_1 = __importStar(require("react"));
31
- const ListboxEdit = ({ defaultValue, onSubmit, values, canEdit = true, }) => {
31
+ const ListboxEdit = ({ defaultValue, onSubmit, values, canEdit = true,
32
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
33
+ renderLabel = (e) => e.toString(), }) => {
32
34
  const [value, setValue] = (0, react_1.useState)(defaultValue);
33
35
  (0, react_1.useEffect)(() => {
34
36
  setValue(defaultValue);
35
37
  }, [defaultValue]);
36
38
  return (react_1.default.createElement(common_1.ValueBox, Object.assign({}, common_2.noDrag),
37
- react_1.default.createElement("select", { size: 5, value: value, onChange: (v) => canEdit ? setValue(v.target.value) : onSubmit(v.target.value) }, values.map((v) => (react_1.default.createElement("option", { key: v, value: v }, v)))),
39
+ react_1.default.createElement("select", { size: 5,
40
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
41
+ value: value.toString(), onChange: (v) => canEdit
42
+ ? setValue(v.target.value)
43
+ : onSubmit(v.target.value) }, values.map((v) => (react_1.default.createElement("option", {
44
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
45
+ key: value.toString(),
46
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
47
+ value: value.toString() }, renderLabel(v))))),
38
48
  canEdit && value !== defaultValue && (react_1.default.createElement(common_1.IconD, { style: common_1.iconLeft, onClick: () => value !== defaultValue && onSubmit(value) },
39
49
  react_1.default.createElement(images_1.SaveIcon, null))),
40
50
  canEdit && value !== defaultValue && (react_1.default.createElement(common_1.IconD, { style: common_1.iconRight, onClick: () => setValue(defaultValue) },
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const RadioGroup: <T>({ defaultValue, onSubmit, values, renderLabel, renderValue, }: {
3
2
  /**
4
3
  * can overload the render of the label. defaults to toString
@@ -40,12 +40,15 @@ renderLabel = (e) => e.toString(),
40
40
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
41
41
  renderValue = (e) => e.toString(), }) => {
42
42
  const [name] = (0, react_1.useState)((0, math_1.getRandomInt)(10000).toString());
43
- const [value, setValue] = (0, react_1.useState)(defaultValue);
43
+ const [value, setValue] = (0, react_1.useState)(renderValue(defaultValue));
44
44
  (0, react_1.useEffect)(() => {
45
- setValue(defaultValue);
46
- }, [defaultValue]);
45
+ const rv = renderValue(defaultValue);
46
+ if (value !== rv) {
47
+ setValue(rv);
48
+ }
49
+ }, [defaultValue, renderValue, value]);
47
50
  return (react_1.default.createElement(common_1.ValueBox, Object.assign({}, common_2.noDrag), values.map((v) => (react_1.default.createElement(FlexColumn_1.FlexColumn, { key: name + v },
48
51
  react_1.default.createElement(Label, null, renderLabel(v)),
49
- react_1.default.createElement("input", { type: "radio", key: renderValue(v), value: renderValue(v), name: name, checked: v === value, onChange: () => onSubmit(v) }))))));
52
+ react_1.default.createElement("input", { type: "radio", key: renderValue(v), value: renderValue(v), name: name, checked: renderValue(v) === value, onChange: () => onSubmit(v) }))))));
50
53
  };
51
54
  exports.RadioGroup = RadioGroup;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { ITextEdit } from './types';
3
2
  import { StyledComponent } from 'styled-components';
4
3
  export declare const ValueReadonly: StyledComponent<"div", any, {}, never>;
@@ -124,7 +124,7 @@ const TextEdit = ({ defaultValue = '', defaultEditing, disableEdit = false, plac
124
124
  if (!editing || disableEdit) {
125
125
  return (react_1.default.createElement(common_1.ValueBox, Object.assign({}, common_2.noDrag, { className: className, "data-editing": "false", onClick: () => onClickNotEditing === null || onClickNotEditing === void 0 ? void 0 : onClickNotEditing(), "data-pointer": onClickNotEditing ? 'true' : 'false', "data-nogrow": noGrow }, attributes),
126
126
  leftContent || null,
127
- react_1.default.createElement(exports.ValueReadonly, { "data-type": "text" }, value),
127
+ react_1.default.createElement(exports.ValueReadonly, { "data-type": "text" }, value || react_1.default.createElement("span", { style: { color: '#ccc' } }, placeholder)),
128
128
  react_1.default.createElement(Right, null, !disableEdit && (react_1.default.createElement(Icon, { style: common_1.iconRight, onClick: (e) => {
129
129
  e.stopPropagation();
130
130
  setEditing(true);
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const UndoIcon: () => JSX.Element;
3
2
  export declare const PencilIcon: () => JSX.Element;
4
3
  export declare const SaveIcon: () => JSX.Element;
@@ -1,10 +1,9 @@
1
- /// <reference types="react" />
2
1
  import { ToastPosition } from 'react-hot-toast';
3
2
  export interface IToastOptions {
4
3
  appearance: 'error' | 'success';
5
4
  autoClose?: number;
6
5
  }
7
- export declare const addToast: (m: string, options?: IToastOptions | undefined) => void;
6
+ export declare const addToast: (m: string, options?: IToastOptions) => void;
8
7
  export declare const ToastProvider: ({ position }: {
9
8
  position: ToastPosition;
10
9
  }) => JSX.Element;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { User } from '../../helpers/jwt';
3
2
  export declare const UserImageIcon: JSX.Element;
4
3
  export declare const UserImage: ({ image, className, }: {
@@ -1,2 +1,2 @@
1
1
  export declare const daydiffstr: (dayticks: number) => string;
2
- export declare const getDMY: (date: Date, dayOffset?: number | undefined) => string;
2
+ export declare const getDMY: (date: Date, dayOffset?: number) => string;
@@ -74,5 +74,5 @@ export interface AuthedUserContext {
74
74
  refreshToken: () => Promise<User | undefined>;
75
75
  }
76
76
  export declare const getBearerToken: (jwt?: {
77
- id_token?: string | undefined;
78
- } | undefined) => string | undefined;
77
+ id_token?: string;
78
+ }) => string | undefined;
@@ -1,5 +1,5 @@
1
1
  export declare const clearLocalStorageItem: (key: string) => void;
2
- export declare const clearAllLocalStorage: (except?: string[] | undefined) => void;
3
- export declare const setLocalStorageItem: <T>(key: string, value: T, ttl?: number | undefined) => void;
4
- export declare const getLocalStorageItem: <T>(key: string, initialValue: T, ttl?: number | undefined) => T;
2
+ export declare const clearAllLocalStorage: (except?: string[]) => void;
3
+ export declare const setLocalStorageItem: <T>(key: string, value: T, ttl?: number) => void;
4
+ export declare const getLocalStorageItem: <T>(key: string, initialValue: T, ttl?: number) => T;
5
5
  export declare function UseLocalStorage<T>(key: string, initialValue: T, ttl?: number): [T, (value: T | ((a: T) => T)) => void];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ag-common",
3
- "version": "0.0.252",
3
+ "version": "0.0.255",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "author": "Andrei Gec <@andreigec> (https://gec.dev/)",
@@ -30,22 +30,22 @@
30
30
  "typescript": "4.x"
31
31
  },
32
32
  "devDependencies": {
33
- "@babel/core": "7.18.0",
34
- "@storybook/addon-actions": "6.5.4",
35
- "@storybook/addon-docs": "6.5.4",
36
- "@storybook/addon-essentials": "6.5.4",
37
- "@storybook/addon-interactions": "6.5.4",
38
- "@storybook/addon-links": "6.5.4",
39
- "@storybook/addons": "6.5.4",
40
- "@storybook/react": "6.5.4",
41
- "@storybook/theming": "6.5.4",
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",
42
42
  "@types/jsonwebtoken": "8.5.8",
43
- "@types/node": "17.0.35",
43
+ "@types/node": "17.0.36",
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.25.0",
48
- "@typescript-eslint/parser": "5.25.0",
47
+ "@typescript-eslint/eslint-plugin": "5.27.0",
48
+ "@typescript-eslint/parser": "5.27.0",
49
49
  "cross-env": "7.0.3",
50
50
  "eslint": "8.16.0",
51
51
  "eslint-config-airbnb-typescript": "17.0.0",