onekijs-ui 1.0.5 → 1.0.6
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/dist/components/datetime/FormDatePicker.d.ts +28 -0
- package/dist/components/datetime/FormDateRangePicker.d.ts +28 -0
- package/dist/components/datetime/FormDateTimePicker.d.ts +21 -0
- package/dist/components/datetime/FormDateTimeRangePicker.d.ts +21 -0
- package/dist/components/datetime/hooks/useDateAdapter.d.ts +4 -0
- package/dist/components/datetime/hooks/useDateRangeAdapter.d.ts +5 -0
- package/dist/components/datetime/hooks/useTimestampAdapter.d.ts +8 -0
- package/dist/components/datetime/hooks/useTimestampRangeAdapter.d.ts +17 -2
- package/dist/components/datetime/index.d.ts +8 -8
- package/dist/components/datetime/typings.d.ts +55 -9
- package/dist/index.d.ts +73 -70
- package/dist/index.js +2287 -2100
- package/dist/index.js.map +1 -1
- package/dist/index.module.js +2281 -2102
- package/dist/index.module.js.map +1 -1
- package/package.json +3 -3
- package/src/components/datetime/FormDatePicker.tsx +79 -0
- package/src/components/datetime/FormDateRangePicker.tsx +79 -0
- package/src/components/datetime/FormDateTimePicker.tsx +43 -0
- package/src/components/datetime/FormDateTimeRangePicker.tsx +38 -0
- package/src/components/datetime/components/DatePickerComponent.tsx +8 -4
- package/src/components/datetime/components/DateRangePickerComponent.tsx +8 -4
- package/src/components/datetime/components/DateTimePickerComponent.tsx +8 -4
- package/src/components/datetime/components/DateTimeRangePickerComponent.tsx +8 -4
- package/src/components/datetime/components/TimeComponent.tsx +3 -0
- package/src/components/datetime/components/TimeRangeComponent.tsx +4 -2
- package/src/components/datetime/components/TimeSelectorComponent.tsx +5 -4
- package/src/components/datetime/components/TimeSelectorPartComponent.tsx +16 -1
- package/src/components/datetime/hooks/useDateAdapter.ts +14 -0
- package/src/components/datetime/hooks/useDateRangeAdapter.ts +11 -11
- package/src/components/datetime/hooks/useTimestampAdapter.ts +37 -0
- package/src/components/datetime/hooks/useTimestampRangeAdapter.ts +15 -26
- package/src/components/datetime/style.ts +14 -3
- package/src/components/datetime/typings.ts +66 -10
- package/src/index.ts +96 -130
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { FormDisplayerProps, FormFieldValueDisplayerProps } from 'onekijs-framework';
|
|
2
|
+
import React, { FC } from 'react';
|
|
3
|
+
import { FormDatePickerProps } from './typings';
|
|
4
|
+
export declare const FormDateValueDisplayer: React.FC<FormFieldValueDisplayerProps>;
|
|
5
|
+
export declare const formDateDisplayerProps: (props: FormDatePickerProps<any>) => {
|
|
6
|
+
defaultValue: any;
|
|
7
|
+
isUndefined: (value: any) => boolean;
|
|
8
|
+
Displayer: React.FC<FormDisplayerProps> | ((displayerProps: FormDisplayerProps) => React.JSX.Element);
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* `<FormDatePicker/>` is a DataPicker component designed to be managed by a Form.
|
|
12
|
+
* It must therefore be a nested component of a Form
|
|
13
|
+
*
|
|
14
|
+
* Some properties are handled entirely by a form controller.
|
|
15
|
+
* * value
|
|
16
|
+
* * onChange
|
|
17
|
+
* * onFocus
|
|
18
|
+
* * onBlur
|
|
19
|
+
* * validations
|
|
20
|
+
* * visibility
|
|
21
|
+
* * disabled
|
|
22
|
+
* The value is synchronized in both directions (it can be modified manually by the user or by the controller).
|
|
23
|
+
*
|
|
24
|
+
* @group Form
|
|
25
|
+
* @category Components
|
|
26
|
+
*/
|
|
27
|
+
declare const FormDatePicker: FC<FormDatePickerProps<any>>;
|
|
28
|
+
export default FormDatePicker;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { FormDisplayerProps, FormFieldValueDisplayerProps } from 'onekijs-framework';
|
|
2
|
+
import React, { FC } from 'react';
|
|
3
|
+
import { FormDateRangePickerProps } from './typings';
|
|
4
|
+
export declare const FormDateRangeValueDisplayer: React.FC<FormFieldValueDisplayerProps>;
|
|
5
|
+
export declare const formDateRangeDisplayerProps: (props: FormDateRangePickerProps<any>) => {
|
|
6
|
+
defaultValue: any;
|
|
7
|
+
isUndefined: (value: any) => boolean;
|
|
8
|
+
Displayer: React.FC<FormDisplayerProps> | ((displayerProps: FormDisplayerProps) => React.JSX.Element);
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* `<FormDateRangePicker/>` is a DataPicker component designed to be managed by a Form.
|
|
12
|
+
* It must therefore be a nested component of a Form
|
|
13
|
+
*
|
|
14
|
+
* Some properties are handled entirely by a form controller.
|
|
15
|
+
* * value
|
|
16
|
+
* * onChange
|
|
17
|
+
* * onFocus
|
|
18
|
+
* * onBlur
|
|
19
|
+
* * validations
|
|
20
|
+
* * visibility
|
|
21
|
+
* * disabled
|
|
22
|
+
* The value is synchronized in both directions (it can be modified manually by the user or by the controller).
|
|
23
|
+
*
|
|
24
|
+
* @group Form
|
|
25
|
+
* @category Components
|
|
26
|
+
*/
|
|
27
|
+
declare const FormDateRangePicker: FC<FormDateRangePickerProps<any>>;
|
|
28
|
+
export default FormDateRangePicker;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { FormDateTimePickerProps } from './typings';
|
|
3
|
+
/**
|
|
4
|
+
* `<FormDateTimePicker/>` is a DataTimePicker component designed to be managed by a Form.
|
|
5
|
+
* It must therefore be a nested component of a Form
|
|
6
|
+
*
|
|
7
|
+
* Some properties are handled entirely by a form controller.
|
|
8
|
+
* * value
|
|
9
|
+
* * onChange
|
|
10
|
+
* * onFocus
|
|
11
|
+
* * onBlur
|
|
12
|
+
* * validations
|
|
13
|
+
* * visibility
|
|
14
|
+
* * disabled
|
|
15
|
+
* The value is synchronized in both directions (it can be modified manually by the user or by the controller).
|
|
16
|
+
*
|
|
17
|
+
* @group Form
|
|
18
|
+
* @category Components
|
|
19
|
+
*/
|
|
20
|
+
declare const FormDateTimePicker: FC<FormDateTimePickerProps<any>>;
|
|
21
|
+
export default FormDateTimePicker;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { FormDateTimeRangePickerProps } from './typings';
|
|
3
|
+
/**
|
|
4
|
+
* `<FormDateTimeRangePicker/>` is a DataTimeRangePicker component designed to be managed by a Form.
|
|
5
|
+
* It must therefore be a nested component of a Form
|
|
6
|
+
*
|
|
7
|
+
* Some properties are handled entirely by a form controller.
|
|
8
|
+
* * value
|
|
9
|
+
* * onChange
|
|
10
|
+
* * onFocus
|
|
11
|
+
* * onBlur
|
|
12
|
+
* * validations
|
|
13
|
+
* * visibility
|
|
14
|
+
* * disabled
|
|
15
|
+
* The value is synchronized in both directions (it can be modified manually by the user or by the controller).
|
|
16
|
+
*
|
|
17
|
+
* @group Form
|
|
18
|
+
* @category Components
|
|
19
|
+
*/
|
|
20
|
+
declare const FormDateTimeRangePicker: FC<FormDateTimeRangePickerProps<any>>;
|
|
21
|
+
export default FormDateTimeRangePicker;
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { DateRangeAdapter } from '../typings';
|
|
2
|
+
export declare const dateRangeAdapter: DateRangeAdapter<{
|
|
3
|
+
from: Date | null;
|
|
4
|
+
to: Date | null;
|
|
5
|
+
label?: string | null;
|
|
6
|
+
}>;
|
|
2
7
|
declare const useDateRangeAdapter: () => DateRangeAdapter<{
|
|
3
8
|
from: Date | null;
|
|
4
9
|
to: Date | null;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DateAdapter, TimestampFormat } from '../typings';
|
|
2
|
+
export declare const toTimestamp: (date: string | undefined | null, format: TimestampFormat) => number | null;
|
|
3
|
+
export declare const fromTimestamp: (timestamp: number | undefined | null, format: TimestampFormat) => string | null;
|
|
4
|
+
export declare const timestampAdapter: (format?: TimestampFormat) => DateAdapter<number | null>;
|
|
5
|
+
export declare const timestampSecondAdapter: DateAdapter<number | null>;
|
|
6
|
+
export declare const timestampMilliSecondAdapter: DateAdapter<number | null>;
|
|
7
|
+
declare const useTimestampAdapter: (format?: TimestampFormat) => DateAdapter<number | null>;
|
|
8
|
+
export default useTimestampAdapter;
|
|
@@ -1,5 +1,20 @@
|
|
|
1
|
-
import { DateRangeAdapter } from '../typings';
|
|
2
|
-
declare const
|
|
1
|
+
import { DateRangeAdapter, TimestampFormat } from '../typings';
|
|
2
|
+
export declare const timestampRangeAdapter: (format?: TimestampFormat) => DateRangeAdapter<{
|
|
3
|
+
from: number | null;
|
|
4
|
+
to: number | null;
|
|
5
|
+
label?: string | null;
|
|
6
|
+
}>;
|
|
7
|
+
export declare const timestampSecondRangeAdapter: DateRangeAdapter<{
|
|
8
|
+
from: number | null;
|
|
9
|
+
to: number | null;
|
|
10
|
+
label?: string | null;
|
|
11
|
+
}>;
|
|
12
|
+
export declare const timestampMilliSecondRangeAdapter: DateRangeAdapter<{
|
|
13
|
+
from: number | null;
|
|
14
|
+
to: number | null;
|
|
15
|
+
label?: string | null;
|
|
16
|
+
}>;
|
|
17
|
+
declare const useTimestampRangeAdapter: (format?: TimestampFormat) => DateRangeAdapter<{
|
|
3
18
|
from: number | null;
|
|
4
19
|
to: number | null;
|
|
5
20
|
label?: string | null;
|
|
@@ -12,7 +12,7 @@ export declare const DatePicker: import("styled-components/dist/types").IStyledC
|
|
|
12
12
|
placeholder?: string;
|
|
13
13
|
placement?: import("@popperjs/core").Placement;
|
|
14
14
|
} & {
|
|
15
|
-
adapter?: import("./typings").DateAdapter<any> | undefined;
|
|
15
|
+
adapter?: "date" | "timestamp" | import("./typings").DateAdapter<any> | undefined;
|
|
16
16
|
onChange?: ((value: any) => void) | undefined;
|
|
17
17
|
value?: any;
|
|
18
18
|
}, never> & Partial<Pick<import("../..").StylableProps & {
|
|
@@ -29,7 +29,7 @@ export declare const DatePicker: import("styled-components/dist/types").IStyledC
|
|
|
29
29
|
placeholder?: string;
|
|
30
30
|
placement?: import("@popperjs/core").Placement;
|
|
31
31
|
} & {
|
|
32
|
-
adapter?: import("./typings").DateAdapter<any> | undefined;
|
|
32
|
+
adapter?: "date" | "timestamp" | import("./typings").DateAdapter<any> | undefined;
|
|
33
33
|
onChange?: ((value: any) => void) | undefined;
|
|
34
34
|
value?: any;
|
|
35
35
|
}, never>>> & string & Omit<import("react").FC<import("./typings").DatePickerProps>, keyof import("react").Component<any, {}, any>>;
|
|
@@ -47,7 +47,7 @@ export declare const DateRangePicker: import("styled-components/dist/types").ISt
|
|
|
47
47
|
placeholder?: string;
|
|
48
48
|
placement?: import("@popperjs/core").Placement;
|
|
49
49
|
} & {
|
|
50
|
-
adapter?: import("./typings").DateRangeAdapter<any> | undefined;
|
|
50
|
+
adapter?: "date" | "timestamp" | import("./typings").DateRangeAdapter<any> | undefined;
|
|
51
51
|
closeOnQuickSelect?: boolean;
|
|
52
52
|
onChange?: ((value: any) => void) | undefined;
|
|
53
53
|
quickRanges?: import("onekijs-framework").AnonymousObject<import("./typings").DateStringRange>;
|
|
@@ -66,7 +66,7 @@ export declare const DateRangePicker: import("styled-components/dist/types").ISt
|
|
|
66
66
|
placeholder?: string;
|
|
67
67
|
placement?: import("@popperjs/core").Placement;
|
|
68
68
|
} & {
|
|
69
|
-
adapter?: import("./typings").DateRangeAdapter<any> | undefined;
|
|
69
|
+
adapter?: "date" | "timestamp" | import("./typings").DateRangeAdapter<any> | undefined;
|
|
70
70
|
closeOnQuickSelect?: boolean;
|
|
71
71
|
onChange?: ((value: any) => void) | undefined;
|
|
72
72
|
quickRanges?: import("onekijs-framework").AnonymousObject<import("./typings").DateStringRange>;
|
|
@@ -86,7 +86,7 @@ export declare const DateTimePicker: import("styled-components/dist/types").ISty
|
|
|
86
86
|
placeholder?: string;
|
|
87
87
|
placement?: import("@popperjs/core").Placement;
|
|
88
88
|
} & {
|
|
89
|
-
adapter?: import("./typings").DateAdapter<any> | undefined;
|
|
89
|
+
adapter?: "date" | "timestamp" | import("./typings").DateAdapter<any> | undefined;
|
|
90
90
|
onChange?: ((value: any) => void) | undefined;
|
|
91
91
|
value?: any;
|
|
92
92
|
} & import("./typings").DisplayTime, never> & Partial<Pick<import("../..").StylableProps & {
|
|
@@ -103,7 +103,7 @@ export declare const DateTimePicker: import("styled-components/dist/types").ISty
|
|
|
103
103
|
placeholder?: string;
|
|
104
104
|
placement?: import("@popperjs/core").Placement;
|
|
105
105
|
} & {
|
|
106
|
-
adapter?: import("./typings").DateAdapter<any> | undefined;
|
|
106
|
+
adapter?: "date" | "timestamp" | import("./typings").DateAdapter<any> | undefined;
|
|
107
107
|
onChange?: ((value: any) => void) | undefined;
|
|
108
108
|
value?: any;
|
|
109
109
|
} & import("./typings").DisplayTime, never>>> & string & Omit<import("react").FC<import("./typings").DateTimePickerProps>, keyof import("react").Component<any, {}, any>>;
|
|
@@ -121,7 +121,7 @@ export declare const DateTimeRangePicker: import("styled-components/dist/types")
|
|
|
121
121
|
placeholder?: string;
|
|
122
122
|
placement?: import("@popperjs/core").Placement;
|
|
123
123
|
} & {
|
|
124
|
-
adapter?: import("./typings").DateRangeAdapter<any> | undefined;
|
|
124
|
+
adapter?: "date" | "timestamp" | import("./typings").DateRangeAdapter<any> | undefined;
|
|
125
125
|
closeOnQuickSelect?: boolean;
|
|
126
126
|
onChange?: ((value: any) => void) | undefined;
|
|
127
127
|
quickRanges?: import("onekijs-framework").AnonymousObject<import("./typings").DateStringRange>;
|
|
@@ -140,7 +140,7 @@ export declare const DateTimeRangePicker: import("styled-components/dist/types")
|
|
|
140
140
|
placeholder?: string;
|
|
141
141
|
placement?: import("@popperjs/core").Placement;
|
|
142
142
|
} & {
|
|
143
|
-
adapter?: import("./typings").DateRangeAdapter<any> | undefined;
|
|
143
|
+
adapter?: "date" | "timestamp" | import("./typings").DateRangeAdapter<any> | undefined;
|
|
144
144
|
closeOnQuickSelect?: boolean;
|
|
145
145
|
onChange?: ((value: any) => void) | undefined;
|
|
146
146
|
quickRanges?: import("onekijs-framework").AnonymousObject<import("./typings").DateStringRange>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Placement } from '@popperjs/core';
|
|
2
|
+
import { AnonymousObject, FormFieldProps } from 'onekijs-framework';
|
|
2
3
|
import { StylableProps } from '../../styles/typings';
|
|
3
4
|
import { DropdownWidthModifier } from '../dropdown/typings';
|
|
4
|
-
import {
|
|
5
|
+
import { FieldDisplayerProps, FieldLayoutProps } from '../field/typings';
|
|
5
6
|
export type BasePickerProps = StylableProps & {
|
|
6
7
|
animationMs?: number;
|
|
7
8
|
attachDropdownToBody?: boolean;
|
|
@@ -57,7 +58,7 @@ export type DatePickerDate = {
|
|
|
57
58
|
second?: string;
|
|
58
59
|
};
|
|
59
60
|
export type DatePickerProps<T extends any = any> = BasePickerProps & {
|
|
60
|
-
adapter?: DateAdapter<T
|
|
61
|
+
adapter?: DateAdapter<T> | 'timestamp' | 'date';
|
|
61
62
|
onChange?: (value: T | null) => void;
|
|
62
63
|
value?: T | null;
|
|
63
64
|
};
|
|
@@ -81,17 +82,12 @@ export type DateStringRange = {
|
|
|
81
82
|
to: string | null;
|
|
82
83
|
label?: string | null;
|
|
83
84
|
};
|
|
84
|
-
export type TimestampRange = {
|
|
85
|
-
from: number | null;
|
|
86
|
-
to: number | null;
|
|
87
|
-
label?: string | null;
|
|
88
|
-
};
|
|
89
85
|
export type DateRangeAdapter<T extends any = any> = {
|
|
90
86
|
fromDateRange: (range: DateStringRange) => T;
|
|
91
87
|
toDateRange: (value: T) => DateStringRange;
|
|
92
88
|
};
|
|
93
89
|
export type DateRangePickerProps<T extends any = any> = BasePickerProps & {
|
|
94
|
-
adapter?: DateRangeAdapter<T
|
|
90
|
+
adapter?: DateRangeAdapter<T> | 'timestamp' | 'date';
|
|
95
91
|
closeOnQuickSelect?: boolean;
|
|
96
92
|
onChange?: (value: T | null) => void;
|
|
97
93
|
quickRanges?: AnonymousObject<DateStringRange>;
|
|
@@ -105,6 +101,46 @@ export type DisplayTime = {
|
|
|
105
101
|
displayMinutes?: boolean;
|
|
106
102
|
displaySeconds?: boolean;
|
|
107
103
|
};
|
|
104
|
+
export type FormDatePickerProps<T> = DatePickerProps<T> & FormFieldProps & FieldLayoutProps & {
|
|
105
|
+
/**
|
|
106
|
+
* The default value of the field if no specific value has been specified
|
|
107
|
+
* A value can be passed to field
|
|
108
|
+
* * either manually by the user filling the form
|
|
109
|
+
* * via the setValue of the form controller (if the field is inside a <Form> component)
|
|
110
|
+
* * via an initial value transmitted to the form
|
|
111
|
+
*
|
|
112
|
+
* @remarks #important#
|
|
113
|
+
*/
|
|
114
|
+
defaultValue?: T;
|
|
115
|
+
/**
|
|
116
|
+
* There are three components used to display the value of an FormInput in the summary step
|
|
117
|
+
* * Displayer: display (label + value)
|
|
118
|
+
* * FieldDisplayer: extract the value from the field and display it
|
|
119
|
+
* * ValueDisplayer: customize how the value is displayed
|
|
120
|
+
*/
|
|
121
|
+
FieldDisplayer?: React.FC<FieldDisplayerProps>;
|
|
122
|
+
};
|
|
123
|
+
export type FormDateRangePickerProps<T> = DateRangePickerProps<T> & FormFieldProps & FieldLayoutProps & {
|
|
124
|
+
/**
|
|
125
|
+
* The default value of the field if no specific value has been specified
|
|
126
|
+
* A value can be passed to field
|
|
127
|
+
* * either manually by the user filling the form
|
|
128
|
+
* * via the setValue of the form controller (if the field is inside a <Form> component)
|
|
129
|
+
* * via an initial value transmitted to the form
|
|
130
|
+
*
|
|
131
|
+
* @remarks #important#
|
|
132
|
+
*/
|
|
133
|
+
defaultValue?: T;
|
|
134
|
+
/**
|
|
135
|
+
* There are three components used to display the value of an FormInput in the summary step
|
|
136
|
+
* * Displayer: display (label + value)
|
|
137
|
+
* * FieldDisplayer: extract the value from the field and display it
|
|
138
|
+
* * ValueDisplayer: customize how the value is displayed
|
|
139
|
+
*/
|
|
140
|
+
FieldDisplayer?: React.FC<FieldDisplayerProps>;
|
|
141
|
+
};
|
|
142
|
+
export type FormDateTimePickerProps<T> = FormDatePickerProps<T> & DisplayTime;
|
|
143
|
+
export type FormDateTimeRangePickerProps<T> = FormDateRangePickerProps<T> & DisplayTime;
|
|
108
144
|
export type PickerComponentProps = BasePickerProps & DisplayTime & {
|
|
109
145
|
closeOnQuickSelect?: boolean;
|
|
110
146
|
type: DatePickerType;
|
|
@@ -124,6 +160,7 @@ export type TimeComponentProps = StylableProps & Required<DisplayTime> & {
|
|
|
124
160
|
to: DatePickerDate;
|
|
125
161
|
type: DatePickerType;
|
|
126
162
|
onChange: (value: string, edge: 'from' | 'to') => void;
|
|
163
|
+
displayHeaders?: boolean;
|
|
127
164
|
};
|
|
128
165
|
export type TimePickerProps = BasePickerProps & DisplayTime & {
|
|
129
166
|
onChange?: (value: string | null) => void;
|
|
@@ -134,8 +171,10 @@ export type TimeRangeComponentProps = Required<DisplayTime> & {
|
|
|
134
171
|
value: DatePickerDate;
|
|
135
172
|
type: DatePickerType;
|
|
136
173
|
onChange: (value: string, edge: 'from' | 'to') => void;
|
|
174
|
+
displayHeaders?: boolean;
|
|
137
175
|
};
|
|
138
176
|
export type TimeSelectorComponentProps = Required<DisplayTime> & {
|
|
177
|
+
displayHeaders?: boolean;
|
|
139
178
|
edge: 'from' | 'to';
|
|
140
179
|
value: DatePickerDate;
|
|
141
180
|
onChange: (value: string, edge: 'from' | 'to') => void;
|
|
@@ -146,4 +185,11 @@ export type TimeSelectorPartComponentProps = {
|
|
|
146
185
|
value: string | number;
|
|
147
186
|
onChange: (value: string) => void;
|
|
148
187
|
size?: 'small' | 'large';
|
|
188
|
+
displayHeaders?: boolean;
|
|
189
|
+
};
|
|
190
|
+
export type TimestampFormat = 'seconds' | 'milliseconds';
|
|
191
|
+
export type TimestampRange = {
|
|
192
|
+
from: number | null;
|
|
193
|
+
to: number | null;
|
|
194
|
+
label?: string | null;
|
|
149
195
|
};
|