@edvisor/product-language 0.10.53 → 0.11.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,5 +1,7 @@
1
1
  import { BadgeTypeProps } from './badge-type-flags';
2
2
  import { FC, PropsWithChildren } from '@helpers';
3
- declare type IBadgeProps = BadgeTypeProps & PropsWithChildren;
3
+ declare type IBadgeProps = BadgeTypeProps & PropsWithChildren<{
4
+ className?: string;
5
+ }>;
4
6
  export declare const Badge: FC<IBadgeProps>;
5
7
  export {};
@@ -1,4 +1,19 @@
1
1
  import { FC } from '@helpers';
2
2
  import { IDatePickerProps as IBaseProps, IDatePickerSlots } from './helpers/date-picker-factory';
3
3
  export declare type IDatePickerProps = IBaseProps<string>;
4
+ /** did you know, if you need a DatePicker that takes something other than
5
+ * string dates, you can use the datePickerFactory? Just supply it with
6
+ * functions to and from your date representation, and an "empty" value for
7
+ * your type.
8
+ *
9
+ * For example, here's one that takes native Date objects
10
+ * ```
11
+ export const DatePicker: FC<IBaseProps<Date>, IDatePickerSlots> = datePickerFactory({
12
+ toDate: (date) => date,
13
+ fromDate: (date) => date,
14
+ empty: (date) => date.getTime() === 0,
15
+ })
16
+ ```
17
+ *
18
+ */
4
19
  export declare const DatePicker: FC<IDatePickerProps, IDatePickerSlots>;
@@ -24,5 +24,6 @@ export * from './modal';
24
24
  export * from './progress-bar';
25
25
  export * from './pagination';
26
26
  export * from './toast';
27
+ export * from './table';
27
28
  export * from './molecules';
28
29
  export * from './organisms';
@@ -1,3 +1,4 @@
1
1
  export * from './avatar';
2
2
  export * from './button';
3
3
  export * from './input-checkbox';
4
+ export * from './simple-menu';
@@ -0,0 +1,15 @@
1
+ /// <reference types="react" />
2
+ export declare const SimpleMenu: import("styled-components").StyledComponent<import("@helpers").FC<import("components/card").ICardProps, {
3
+ Section: typeof import("../../card/components").CardSectionSlot;
4
+ Controls: typeof import("../../card/components").CardControlsSlot;
5
+ HeadingAction: typeof import("../../card/components").CardHeadingActionSlot;
6
+ AlertBanner: typeof import("../../card/components").CardAlertBannerSlot;
7
+ }>, any, {}, never>;
8
+ export declare const SimpleMenuItem: import("styled-components").StyledComponent<"li", any, {}, never>;
9
+ export declare function useSimpleMenuState(): {
10
+ isOpen: boolean;
11
+ toggle: () => void;
12
+ open: () => void;
13
+ close: () => void;
14
+ clickOutsideRef: import("react").RefObject<HTMLDivElement>;
15
+ };
@@ -0,0 +1 @@
1
+ export * from './SimpleMenu';
@@ -0,0 +1,4 @@
1
+ export * from './useTable';
2
+ export * from './useFilteredRows';
3
+ export * from './usePaginatedRows';
4
+ export * from './useSortedRows';
@@ -0,0 +1,5 @@
1
+ export interface IFilter<D> {
2
+ fn?: string | ((el: D) => boolean);
3
+ mode?: 'fuzzy' | 'exact';
4
+ }
5
+ export declare function useFilteredRows<D>(data: D[], state: IFilter<D>): D[];
@@ -0,0 +1,12 @@
1
+ export interface IPagination {
2
+ pageIndex: number;
3
+ pageSize: number;
4
+ }
5
+ export declare function usePaginatedRows<D>(data: D[], pagination: IPagination): {
6
+ rows: D[];
7
+ pagination: {
8
+ pageIndex: number;
9
+ pageCount: number;
10
+ pageSize: number;
11
+ };
12
+ };
@@ -0,0 +1,6 @@
1
+ export interface ISort<D> {
2
+ direction: 'ASC' | 'DESC' | 'NONE';
3
+ getter: (a: D) => D[keyof D];
4
+ }
5
+ /** runs the given rows through each of the sort functions */
6
+ export declare function useSortedRows<D>(data: D[], sort: ISort<D>[]): D[];
@@ -0,0 +1,47 @@
1
+ import { IPagination } from './usePaginatedRows';
2
+ import { ISort } from './useSortedRows';
3
+ import { IFilter } from './useFilteredRows';
4
+ export interface IUseTableProps<D> {
5
+ data: D[];
6
+ initialState: IInitialTableState<D>;
7
+ }
8
+ export interface IUseTableResult<D> {
9
+ rows: D[];
10
+ allRows: D[];
11
+ goto: (pageIndex: number) => void;
12
+ sortBy: (sort: {
13
+ id: string;
14
+ getter: (el: D) => D[keyof D];
15
+ }) => void;
16
+ getSort: (id: string) => 'ASC' | 'DESC' | 'NONE';
17
+ filterBy: (filter: string | ((el: D) => boolean)) => void;
18
+ pagination: {
19
+ pageIndex: number;
20
+ pageSize: number;
21
+ pageCount: number;
22
+ };
23
+ }
24
+ export declare function useTable<D>(props: IUseTableProps<D>): IUseTableResult<D>;
25
+ export interface ITableState<D> {
26
+ pagination: IPagination;
27
+ filter: IFilter<D>;
28
+ sort: (ISort<D> & {
29
+ id: string;
30
+ })[];
31
+ }
32
+ interface IInitialTableState<D> {
33
+ pagination?: {
34
+ pageIndex: number;
35
+ pageSize: number;
36
+ };
37
+ filter?: {
38
+ fn: string | ((el: D) => boolean);
39
+ mode: 'fuzzy' | 'exact';
40
+ };
41
+ sort?: {
42
+ id: string;
43
+ getter: (a: D) => D[keyof D];
44
+ direction: 'ASC' | 'DESC';
45
+ }[];
46
+ }
47
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from './table';
2
+ export * from './hooks';
@@ -0,0 +1,28 @@
1
+ import { FC } from '@helpers';
2
+ import { HTMLAttributes } from 'react';
3
+ export declare const Table: import("styled-components").StyledComponent<"table", any, {}, never>;
4
+ export declare const TBody: import("styled-components").StyledComponent<"tbody", any, {}, never>;
5
+ export declare const TableHeaderFrame: import("styled-components").StyledComponent<"th", any, {}, never>;
6
+ export interface ITHProps extends HTMLAttributes<HTMLTableCellElement> {
7
+ isPlaceholder?: boolean;
8
+ sort?: 'ASC' | 'DESC' | 'NONE';
9
+ }
10
+ declare type THSubComponents = {
11
+ Select: FC;
12
+ Actions: FC;
13
+ };
14
+ export declare const TH: FC<ITHProps, THSubComponents>;
15
+ export interface ITDProps extends HTMLAttributes<HTMLTableCellElement> {
16
+ fitContent?: boolean;
17
+ }
18
+ declare type TDSubComponents = {
19
+ Select: FC;
20
+ Actions: FC;
21
+ Action: FC;
22
+ };
23
+ export declare const TD: FC<ITDProps, TDSubComponents>;
24
+ export declare const TR: import("styled-components").StyledComponent<"tr", any, {
25
+ selected?: boolean | undefined;
26
+ }, never>;
27
+ export declare const THead: import("styled-components").StyledComponent<"thead", any, {}, never>;
28
+ export {};
@@ -7,3 +7,4 @@ export * from './strings';
7
7
  export * from './isReactElementOfType';
8
8
  export * from './useInputElementState';
9
9
  export * from './useIsMobile';
10
+ export * from './useClickOutside';
@@ -3,7 +3,8 @@ import isString from 'lodash/isString.js';
3
3
  import isFunction from 'lodash/isFunction.js';
4
4
  import uniqueId from 'lodash/uniqueId.js';
5
5
  import debounce from 'lodash/debounce.js';
6
- export { first, isString, isFunction, uniqueId, debounce, };
6
+ import isObject from 'lodash/isObject';
7
+ export { first, isString, isFunction, uniqueId, debounce, isObject };
7
8
  /** even though we have null disabled in the repo,
8
9
  * I still would not want isNil to skip checking null
9
10
  * it is for juuuuust in case a third party sends us a null
@@ -0,0 +1,2 @@
1
+ import * as React from 'react';
2
+ export declare function useOnClickOutside(handler: (event: Event) => void): React.RefObject<HTMLDivElement>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edvisor/product-language",
3
- "version": "0.10.53",
3
+ "version": "0.11.1",
4
4
  "license": "MIT",
5
5
  "description": "Edvisor.io product-language components",
6
6
  "repository": "https://github.com/edvisor-io/front-end/",