kelt-ui-kit-react 2.0.0 → 2.0.2

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.
package/README.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # Getting Started with Create React App
2
2
 
3
+ ## Address search
4
+
5
+ Use the `ADDRESS` field type to add geocoding directly to an address field.
6
+ The user can keep any manually entered value, while selecting a suggestion can
7
+ populate the rest of the form:
8
+
9
+ ```tsx
10
+ {
11
+ name: "adresse1",
12
+ label: "Adresse",
13
+ type: TypeInputEnum.ADDRESS,
14
+ value: "",
15
+ addressSearch: {
16
+ mapAddress: (address) => ({
17
+ adresse1: address.addressLine,
18
+ codePostal: address.postalCode,
19
+ ville: address.city,
20
+ paysIso2: address.countryCode,
21
+ }),
22
+ },
23
+ };
24
+ ```
25
+
26
+ Use `addressSearch.provider` to inject another service implementing
27
+ `GeocodingProvider`. The default provider does not require an API key.
28
+
3
29
  This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
4
30
 
5
31
  ## Available Scripts
@@ -0,0 +1,20 @@
1
+ import { GeocodedAddress, GeocodingProvider } from '../geocoding/geocoding.interface';
2
+
3
+ export interface AddressSearchProps {
4
+ id?: string;
5
+ className?: string;
6
+ label?: string;
7
+ placeholder?: string;
8
+ value?: string;
9
+ disabled?: boolean;
10
+ minimumQueryLength?: number;
11
+ debounceTime?: number;
12
+ limit?: number;
13
+ provider?: GeocodingProvider;
14
+ allowManualEntry?: boolean;
15
+ manualEntryLabel?: string;
16
+ onChange?: (value: string) => void;
17
+ onManualEntry?: (addressLine: string) => void;
18
+ onSelect: (address: GeocodedAddress) => void;
19
+ }
20
+ export declare const AddressSearch: ({ id, className, label, placeholder, value, disabled, minimumQueryLength, debounceTime, limit, provider, allowManualEntry, manualEntryLabel, onChange, onManualEntry, onSelect, }: AddressSearchProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export declare const AddressSearchView: () => import("react/jsx-runtime").JSX.Element;
@@ -29,5 +29,6 @@ export type DataTableProps<T> = {
29
29
  onRowClassName?: (row: T) => string | undefined;
30
30
  rowStyle?: (row: T) => React.CSSProperties | undefined;
31
31
  rowClassName?: (row: T) => string | undefined;
32
+ mobileCardView?: boolean;
32
33
  };
33
34
  export declare function DataTable<T>(props: DataTableProps<T>): import("react/jsx-runtime").JSX.Element;
@@ -5,7 +5,8 @@ type DataTableRowProps = {
5
5
  idx: number;
6
6
  rowIndex: number;
7
7
  row: any;
8
+ container?: "cell" | "card";
8
9
  onEnterNextColumn?: (columnIndex: number, rowIndex: number) => void;
9
10
  };
10
- export declare const DataTableRow: ({ column, idx, rowIndex, row, onEnterNextColumn, }: DataTableRowProps) => import("react/jsx-runtime").JSX.Element;
11
+ export declare const DataTableRow: ({ column, idx, rowIndex, row, container, onEnterNextColumn, }: DataTableRowProps) => import("react/jsx-runtime").JSX.Element;
11
12
  export {};
@@ -1,5 +1,5 @@
1
1
  import { default as React } from 'react';
2
- import { FormInterface, FormMode, FormValuesInterface } from './form.interface';
2
+ import { FormInterface, FormMode, FormSection, FormValuesInterface } from './form.interface';
3
3
 
4
4
  export type FormProps<T extends {
5
5
  [key: string]: string | number | boolean | Date | string[];
@@ -10,7 +10,8 @@ export type FormProps<T extends {
10
10
  hideSubmit?: boolean;
11
11
  autoComplete?: string;
12
12
  children?: React.ReactNode;
13
- initialForm: FormInterface[];
13
+ initialForm?: FormInterface[];
14
+ sections?: FormSection[];
14
15
  disabledSubmit?: boolean;
15
16
  mode?: FormMode;
16
17
  onSubmit?: (values: FormValuesInterface<T>) => void;
@@ -1,4 +1,5 @@
1
1
  export declare enum TypeInputEnum {
2
+ ADDRESS = "address",
2
3
  TEXT = "text",
3
4
  BUTTON = "button",
4
5
  EMAIL = "email",
@@ -1,5 +1,6 @@
1
1
  import { TypeInputEnum } from './form.enum';
2
2
  import { GridBreakpoints } from '../grid/grid.interface';
3
+ import { GeocodedAddress, GeocodingProvider } from '../geocoding/geocoding.interface';
3
4
 
4
5
  export type FormMode = "read" | "edit";
5
6
  export type FormValuesInterface<T extends {
@@ -11,6 +12,11 @@ export interface FormCondition {
11
12
  errorMessage: string;
12
13
  regex: string;
13
14
  }
15
+ export interface FormSection {
16
+ title?: React.ReactNode;
17
+ fields: FormInterface[];
18
+ className?: string;
19
+ }
14
20
  export interface FormInterface {
15
21
  value: string | number | boolean | Date;
16
22
  id?: string;
@@ -30,6 +36,15 @@ export interface FormInterface {
30
36
  }[];
31
37
  className?: string;
32
38
  col?: GridBreakpoints;
39
+ addressSearch?: {
40
+ minimumQueryLength?: number;
41
+ debounceTime?: number;
42
+ limit?: number;
43
+ provider?: GeocodingProvider;
44
+ manualEntryLabel?: string;
45
+ mapAddress?: (address: GeocodedAddress) => Record<string, string | number | boolean | Date | string[]>;
46
+ onSelect?: (address: GeocodedAddress) => void;
47
+ };
33
48
  formatReadValue?: (value: string | number | boolean | Date | string[]) => React.ReactNode;
34
49
  autoComplete?: string;
35
50
  step?: string;
@@ -0,0 +1,13 @@
1
+ import { GeocodedAddress, GeocodingProvider, GeocodingSearchOptions } from './geocoding.interface';
2
+
3
+ export interface GeocodingServiceOptions {
4
+ baseUrl?: string;
5
+ fetcher?: typeof fetch;
6
+ }
7
+ export declare class GeocodingService implements GeocodingProvider {
8
+ private readonly baseUrl;
9
+ private readonly fetcher;
10
+ constructor(options?: GeocodingServiceOptions);
11
+ search(query: string, options?: GeocodingSearchOptions): Promise<GeocodedAddress[]>;
12
+ }
13
+ export declare const geocodingService: GeocodingService;
@@ -0,0 +1,20 @@
1
+ export interface GeocodedAddress {
2
+ id: string;
3
+ label: string;
4
+ addressLine: string;
5
+ postalCode: string;
6
+ city: string;
7
+ cityCode?: string;
8
+ countryCode: string;
9
+ longitude: number;
10
+ latitude: number;
11
+ score?: number;
12
+ type?: string;
13
+ }
14
+ export interface GeocodingSearchOptions {
15
+ limit?: number;
16
+ signal?: AbortSignal;
17
+ }
18
+ export interface GeocodingProvider {
19
+ search(query: string, options?: GeocodingSearchOptions): Promise<GeocodedAddress[]>;
20
+ }
package/dist/index.d.ts CHANGED
@@ -11,6 +11,8 @@ export { useToken } from './_core/hooks/useToken';
11
11
  export { useValidate } from './_core/hooks/useValidate';
12
12
  export { WidgetSupport } from './_core/hooks/widgetSupport';
13
13
  export { ButtonAction } from './action/ButtonAction';
14
+ export { AddressSearch } from './addressSearch/AddressSearch';
15
+ export type { AddressSearchProps } from './addressSearch/AddressSearch';
14
16
  export { Badge } from './badge/Badge';
15
17
  export { Button } from './button/Button';
16
18
  export { ButtonActions } from './button/buttonActions/ButtonActions';
@@ -24,12 +26,14 @@ export { Expands } from './expands/Expands';
24
26
  export { FilAriane } from './filAriane/FilAriane';
25
27
  export { DynamicForm } from './form/Form';
26
28
  export { TypeInputEnum } from './form/form.enum';
27
- export type { FormMode } from './form/form.interface';
29
+ export type { FormMode, FormSection } from './form/form.interface';
28
30
  export { Input } from './form/input/Input';
29
31
  export { InputNumber } from './form/inputNumber/InputNumber';
30
32
  export { InputPrice } from './form/inputPrice/InputPrice';
31
33
  export { TextArea } from './form/textArea/TextArea';
32
34
  export { Grid } from './grid/Grid';
35
+ export { GeocodingService, geocodingService, } from './geocoding/GeocodingService';
36
+ export type { GeocodedAddress, GeocodingProvider, GeocodingSearchOptions, } from './geocoding/geocoding.interface';
33
37
  export { Header } from './header/Header';
34
38
  export { Icon } from './icon/Icon';
35
39
  export { IconSizeEnum } from './icon/iconSize.enum';