w-design-system 0.0.27 → 0.0.29
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/.storybook/preview.ts +1 -0
- package/dist/components/DatePicker/index.d.ts +17 -0
- package/dist/components/DatePicker/index.d.ts.map +1 -0
- package/dist/components/DatePicker/index.js +22 -0
- package/dist/components/DatePicker/index.js.map +1 -0
- package/dist/components/DatePicker/stories.d.ts +8 -0
- package/dist/components/DatePicker/stories.d.ts.map +1 -0
- package/dist/components/DatePicker/stories.js +61 -0
- package/dist/components/DatePicker/stories.js.map +1 -0
- package/dist/components/DateRangePicker/index.d.ts +19 -0
- package/dist/components/DateRangePicker/index.d.ts.map +1 -0
- package/dist/components/DateRangePicker/index.js +159 -0
- package/dist/components/DateRangePicker/index.js.map +1 -0
- package/dist/components/DateRangePicker/stories.d.ts +8 -0
- package/dist/components/DateRangePicker/stories.d.ts.map +1 -0
- package/dist/components/DateRangePicker/stories.js +60 -0
- package/dist/components/DateRangePicker/stories.js.map +1 -0
- package/dist/components/DateRangePicker/styles.d.ts +18 -0
- package/dist/components/DateRangePicker/styles.d.ts.map +1 -0
- package/dist/components/DateRangePicker/styles.js +113 -0
- package/dist/components/DateRangePicker/styles.js.map +1 -0
- package/dist/components/Input/index.d.ts +3 -3
- package/dist/components/Input/index.d.ts.map +1 -1
- package/dist/components/Input/index.js +3 -3
- package/dist/components/Input/styles.d.ts.map +1 -1
- package/dist/components/Input/styles.js +29 -13
- package/dist/components/Input/styles.js.map +1 -1
- package/dist/components/Paginate/index.d.ts +2 -2
- package/dist/components/Paginate/stories.d.ts +3 -3
- package/dist/components/Select/index.d.ts +20 -0
- package/dist/components/Select/index.d.ts.map +1 -0
- package/dist/components/Select/index.js +68 -0
- package/dist/components/Select/index.js.map +1 -0
- package/dist/components/Select/stories.d.ts +7 -0
- package/dist/components/Select/stories.d.ts.map +1 -0
- package/dist/components/Select/stories.js +48 -0
- package/dist/components/Select/stories.js.map +1 -0
- package/dist/components/Select/styles.d.ts +8 -0
- package/dist/components/Select/styles.d.ts.map +1 -0
- package/dist/components/Select/styles.js +55 -0
- package/dist/components/Select/styles.js.map +1 -0
- package/dist/components/Themes/index.d.ts +1 -0
- package/dist/components/Themes/index.d.ts.map +1 -1
- package/dist/components/Themes/index.js +5 -2
- package/dist/components/Themes/index.js.map +1 -1
- package/dist/components/Types/index.d.ts +6 -1
- package/dist/components/Types/index.d.ts.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/src/globalStyles.d.ts.map +1 -1
- package/dist/src/globalStyles.js +6 -1
- package/dist/src/globalStyles.js.map +1 -1
- package/package.json +1 -1
- package/src/components/{DateInput → DatePicker}/index.tsx +5 -5
- package/src/components/{DateInput → DatePicker}/stories.tsx +21 -9
- package/src/components/{RangeDateInput → DateRangePicker}/index.tsx +79 -117
- package/src/components/{RangeDateInput → DateRangePicker}/stories.tsx +12 -13
- package/src/components/{DateInput → DateRangePicker}/styles.ts +40 -55
- package/src/components/Input/index.tsx +7 -7
- package/src/components/Input/styles.ts +29 -13
- package/src/components/Paginate/index.tsx +2 -2
- package/src/components/Paginate/stories.tsx +4 -4
- package/src/components/Select/index.tsx +123 -0
- package/src/components/Select/stories.tsx +51 -0
- package/src/components/Select/styles.ts +62 -0
- package/src/components/Themes/index.ts +5 -0
- package/src/components/Types/index.ts +8 -1
- package/src/index.tsx +3 -2
- package/src/reset.css +6 -0
- package/src/src/globalStyles.ts +9 -4
- package/src/components/RangeDateInput/styles.ts +0 -145
package/.storybook/preview.ts
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React, { HTMLAttributes } from 'react';
|
|
2
|
+
export interface DatePickerProps extends HTMLAttributes<HTMLDivElement> {
|
|
3
|
+
placeholder?: string;
|
|
4
|
+
label: string;
|
|
5
|
+
options?: {
|
|
6
|
+
text: string;
|
|
7
|
+
id: number;
|
|
8
|
+
}[];
|
|
9
|
+
selectedOption?: number | null;
|
|
10
|
+
readonly?: boolean;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
onSelectedOptionChange?: (option: number | null) => void;
|
|
13
|
+
customDate: Date | null;
|
|
14
|
+
onSelectedCustomDate?: (date: Date | null) => void;
|
|
15
|
+
}
|
|
16
|
+
export declare const DatePicker: React.FC<DatePickerProps>;
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/DatePicker/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AAG7C,MAAM,WAAW,eAAgB,SAAQ,cAAc,CAAC,cAAc,CAAC;IACrE,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;IACxC,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,sBAAsB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAA;IACxD,UAAU,EAAE,IAAI,GAAG,IAAI,CAAA;IACvB,oBAAoB,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,KAAK,IAAI,CAAA;CACnD;AAED,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAahD,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import { DateRangePicker } from '../DateRangePicker';
|
|
14
|
+
export const DatePicker = (_a) => {
|
|
15
|
+
var { onSelectedCustomDate, customDate } = _a, props = __rest(_a, ["onSelectedCustomDate", "customDate"]);
|
|
16
|
+
const onRangeSelected = (start) => {
|
|
17
|
+
if (onSelectedCustomDate)
|
|
18
|
+
onSelectedCustomDate(start);
|
|
19
|
+
};
|
|
20
|
+
return (React.createElement(DateRangePicker, Object.assign({}, props, { isRange: false, onSelectedCustomRange: onRangeSelected, startCustomDate: customDate, endCustomDate: customDate })));
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/DatePicker/index.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAyB,MAAM,OAAO,CAAA;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAcpD,MAAM,CAAC,MAAM,UAAU,GAA8B,CAAC,EAA8C,EAAE,EAAE;QAAlD,EAAE,oBAAoB,EAAE,UAAU,OAAY,EAAP,KAAK,cAA5C,sCAA8C,CAAF;IAChG,MAAM,eAAe,GAAG,CAAC,KAAkB,EAAE,EAAE;QAC7C,IAAI,oBAAoB;YAAE,oBAAoB,CAAC,KAAK,CAAC,CAAA;IACvD,CAAC,CAAA;IACD,OAAO,CACL,oBAAC,eAAe,oBACV,KAAK,IACT,OAAO,EAAE,KAAK,EACd,qBAAqB,EAAE,eAAe,EACtC,eAAe,EAAE,UAAU,EAC3B,aAAa,EAAE,UAAU,IACzB,CACH,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { DatePicker as DatePicker } from './index';
|
|
3
|
+
declare const meta: Meta<typeof DatePicker>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof DatePicker>;
|
|
6
|
+
export declare const SelecionarDataDeDatas: Story;
|
|
7
|
+
export declare const SelecionarDatasSimples: Story;
|
|
8
|
+
//# sourceMappingURL=stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stories.d.ts","sourceRoot":"","sources":["../../../src/components/DatePicker/stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,UAAU,IAAI,UAAU,EAAE,MAAM,SAAS,CAAA;AAGlD,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,UAAU,CAUC,CAAA;AAEnC,eAAe,IAAI,CAAA;AACnB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,UAAU,CAAC,CAAA;AA4CxC,eAAO,MAAM,qBAAqB,EAAE,KAEnC,CAAA;AAED,eAAO,MAAM,sBAAsB,EAAE,KAEpC,CAAA"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { DatePicker as DatePicker } from './index';
|
|
13
|
+
import React from 'react';
|
|
14
|
+
const meta = {
|
|
15
|
+
title: 'Components/DatePicker',
|
|
16
|
+
component: DatePicker,
|
|
17
|
+
tags: ['autodocs'],
|
|
18
|
+
argTypes: {
|
|
19
|
+
placeholder: { control: 'text' },
|
|
20
|
+
label: { control: 'text' },
|
|
21
|
+
readonly: { control: 'boolean' },
|
|
22
|
+
disabled: { control: 'boolean' },
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
export default meta;
|
|
26
|
+
const ComponentWrapper = (_a) => {
|
|
27
|
+
var { defaultOptions } = _a, args = __rest(_a, ["defaultOptions"]);
|
|
28
|
+
const [selectedOption, setSelectOption] = React.useState(null);
|
|
29
|
+
const [customDate, setCustomDate] = React.useState(null);
|
|
30
|
+
const onSelectedOptionChange = (option) => {
|
|
31
|
+
setSelectOption(option);
|
|
32
|
+
if (option === null) {
|
|
33
|
+
setCustomDate(null);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const date = new Date();
|
|
37
|
+
date.setDate(date.getDate() + option);
|
|
38
|
+
setCustomDate(date);
|
|
39
|
+
};
|
|
40
|
+
return (React.createElement(DatePicker, Object.assign({ selectedOption: selectedOption, customDate: customDate, onSelectedOptionChange: onSelectedOptionChange, onSelectedCustomDate: date => setCustomDate(date), options: defaultOptions !== null && defaultOptions !== void 0 ? defaultOptions : [
|
|
41
|
+
{
|
|
42
|
+
text: 'Ontem',
|
|
43
|
+
id: -1,
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
text: 'Hoje',
|
|
47
|
+
id: 0,
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
text: 'Amanhã',
|
|
51
|
+
id: 1,
|
|
52
|
+
},
|
|
53
|
+
] }, args)));
|
|
54
|
+
};
|
|
55
|
+
export const SelecionarDataDeDatas = {
|
|
56
|
+
render: args => React.createElement(ComponentWrapper, { label: "Data da Disputa", placeholder: "Placeholder" }),
|
|
57
|
+
};
|
|
58
|
+
export const SelecionarDatasSimples = {
|
|
59
|
+
render: args => React.createElement(ComponentWrapper, { defaultOptions: [] }),
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stories.js","sourceRoot":"","sources":["../../../src/components/DatePicker/stories.tsx"],"names":[],"mappings":";;;;;;;;;;;AACA,OAAO,EAAE,UAAU,IAAI,UAAU,EAAE,MAAM,SAAS,CAAA;AAClD,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,MAAM,IAAI,GAA4B;IACpC,KAAK,EAAE,uBAAuB;IAC9B,SAAS,EAAE,UAAU;IACrB,IAAI,EAAE,CAAC,UAAU,CAAC;IAClB,QAAQ,EAAE;QACR,WAAW,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE;QAChC,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE;QAC1B,QAAQ,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE;QAChC,QAAQ,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE;KACjC;CACgC,CAAA;AAEnC,eAAe,IAAI,CAAA;AAGnB,MAAM,gBAAgB,GAAG,CAAC,EAAgC,EAAE,EAAE;QAApC,EAAE,cAAc,OAAgB,EAAX,IAAI,cAAzB,kBAA2B,CAAF;IACjD,MAAM,CAAC,cAAc,EAAE,eAAe,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAgB,IAAI,CAAC,CAAA;IAE7E,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAc,IAAI,CAAC,CAAA;IACrE,MAAM,sBAAsB,GAAG,CAAC,MAAqB,EAAE,EAAE;QACvD,eAAe,CAAC,MAAM,CAAC,CAAA;QACvB,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;YACpB,aAAa,CAAC,IAAI,CAAC,CAAA;YACnB,OAAM;QACR,CAAC;QACD,MAAM,IAAI,GAAG,IAAI,IAAI,EAAE,CAAA;QACvB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,MAAM,CAAC,CAAA;QACrC,aAAa,CAAC,IAAI,CAAC,CAAA;IAErB,CAAC,CAAA;IACD,OAAO,CACL,oBAAC,UAAU,kBACT,cAAc,EAAE,cAAc,EAC9B,UAAU,EAAE,UAAU,EACtB,sBAAsB,EAAE,sBAAsB,EAC9C,oBAAoB,EAAE,IAAI,CAAC,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,EACjD,OAAO,EACL,cAAc,aAAd,cAAc,cAAd,cAAc,GAAI;YAChB;gBACE,IAAI,EAAE,OAAO;gBACb,EAAE,EAAE,CAAC,CAAC;aACP;YACD;gBACE,IAAI,EAAE,MAAM;gBACZ,EAAE,EAAE,CAAC;aACN;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,EAAE,EAAE,CAAC;aACN;SACF,IAEC,IAAI,EACR,CACH,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAU;IAC1C,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,oBAAC,gBAAgB,IAAC,KAAK,EAAC,iBAAiB,EAAC,WAAW,EAAC,aAAa,GAAG;CACvF,CAAA;AAED,MAAM,CAAC,MAAM,sBAAsB,GAAU;IAC3C,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,oBAAC,gBAAgB,IAAC,cAAc,EAAE,EAAE,GAAI;CACzD,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React, { HTMLAttributes } from 'react';
|
|
2
|
+
export interface DateRangePickerProps extends HTMLAttributes<HTMLDivElement> {
|
|
3
|
+
isRange?: boolean;
|
|
4
|
+
placeholder?: string;
|
|
5
|
+
label?: string;
|
|
6
|
+
options?: {
|
|
7
|
+
text: string;
|
|
8
|
+
id: number;
|
|
9
|
+
}[];
|
|
10
|
+
selectedOption?: number | null;
|
|
11
|
+
readonly?: boolean;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
onSelectedOptionChange?: (option: number | null) => void;
|
|
14
|
+
startCustomDate: Date | null;
|
|
15
|
+
endCustomDate: Date | null;
|
|
16
|
+
onSelectedCustomRange: (start: Date | null, end: Date | null) => void;
|
|
17
|
+
}
|
|
18
|
+
export declare const DateRangePicker: React.FC<DateRangePickerProps>;
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/DateRangePicker/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,cAAc,EAAwC,MAAM,OAAO,CAAA;AAcnF,MAAM,WAAW,oBAAqB,SAAQ,cAAc,CAAC,cAAc,CAAC;IAC1E,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;IACxC,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,sBAAsB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAA;IACxD,eAAe,EAAE,IAAI,GAAG,IAAI,CAAA;IAC5B,aAAa,EAAE,IAAI,GAAG,IAAI,CAAA;IAC1B,qBAAqB,EAAE,CAAC,KAAK,EAAE,IAAI,GAAG,IAAI,EAAE,GAAG,EAAE,IAAI,GAAG,IAAI,KAAK,IAAI,CAAA;CACtE;AAmCD,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CA4K1D,CAAA"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
|
13
|
+
import { calendarSVG, chevronLeftSVG, chevronRightSVG } from '../../assets/icon';
|
|
14
|
+
import { IconWrapper } from '../IconWrapper';
|
|
15
|
+
import { Select } from '../Select';
|
|
16
|
+
import { theme } from '../Themes';
|
|
17
|
+
import { CalendarDay, CalendarDaySelectedBackground, CalendarDayValue, CalendarGrid, CalendarHeader, CalendarWeekDayLabel, } from './styles';
|
|
18
|
+
const monthNames = [
|
|
19
|
+
'Janeiro',
|
|
20
|
+
'Fevereiro',
|
|
21
|
+
'Março',
|
|
22
|
+
'Abril',
|
|
23
|
+
'Maio',
|
|
24
|
+
'Junho',
|
|
25
|
+
'Julho',
|
|
26
|
+
'Agosto',
|
|
27
|
+
'Setembro',
|
|
28
|
+
'Outubro',
|
|
29
|
+
'Novembro',
|
|
30
|
+
'Dezembro',
|
|
31
|
+
];
|
|
32
|
+
const weekDays = ['DOM', 'SEG', 'TER', 'QUA', 'QUI', 'SEX', 'SAB'];
|
|
33
|
+
export const DateRangePicker = (_a) => {
|
|
34
|
+
var _b, _c, _d;
|
|
35
|
+
var { label, options, selectedOption, onSelectedOptionChange, placeholder, onSelectedCustomRange, startCustomDate, endCustomDate, isRange } = _a, props = __rest(_a, ["label", "options", "selectedOption", "onSelectedOptionChange", "placeholder", "onSelectedCustomRange", "startCustomDate", "endCustomDate", "isRange"]);
|
|
36
|
+
const [currentYear, setCurrentYear] = useState(0);
|
|
37
|
+
const [currentMonth, setCurrentMonth] = useState(0);
|
|
38
|
+
const [currentMouseHoverDate, setCurrentMouseHoverDate] = useState(null);
|
|
39
|
+
const selectRef = useRef(null);
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
const date = new Date();
|
|
42
|
+
setCurrentYear(date.getFullYear());
|
|
43
|
+
setCurrentMonth(date.getMonth());
|
|
44
|
+
}, []);
|
|
45
|
+
const days = [];
|
|
46
|
+
const changeMonth = (delta) => {
|
|
47
|
+
const newDate = new Date(currentYear, currentMonth + delta);
|
|
48
|
+
setCurrentYear(newDate.getFullYear());
|
|
49
|
+
setCurrentMonth(newDate.getMonth());
|
|
50
|
+
};
|
|
51
|
+
const onSelectedOptionChangeHandler = (option) => {
|
|
52
|
+
var _a;
|
|
53
|
+
if (onSelectedOptionChange) {
|
|
54
|
+
onSelectedOptionChange(option);
|
|
55
|
+
if (onSelectedCustomRange)
|
|
56
|
+
onSelectedCustomRange(null, null);
|
|
57
|
+
(_a = selectRef.current) === null || _a === void 0 ? void 0 : _a.setOpen(false);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
const onDayClick = (date) => {
|
|
61
|
+
var _a, _b, _c;
|
|
62
|
+
if (onSelectedOptionChange)
|
|
63
|
+
onSelectedOptionChange(null);
|
|
64
|
+
if (!startCustomDate) {
|
|
65
|
+
onSelectedCustomRange && onSelectedCustomRange(date, null);
|
|
66
|
+
currentMouseHoverDate && setCurrentMouseHoverDate(date);
|
|
67
|
+
if (isRange === false)
|
|
68
|
+
(_a = selectRef.current) === null || _a === void 0 ? void 0 : _a.setOpen(false);
|
|
69
|
+
}
|
|
70
|
+
else if (!endCustomDate) {
|
|
71
|
+
let firstDate = startCustomDate;
|
|
72
|
+
let secondDate = date;
|
|
73
|
+
if (firstDate && secondDate && firstDate > secondDate) {
|
|
74
|
+
const temp = firstDate;
|
|
75
|
+
firstDate = secondDate;
|
|
76
|
+
secondDate = temp;
|
|
77
|
+
}
|
|
78
|
+
onSelectedCustomRange && onSelectedCustomRange(firstDate, secondDate);
|
|
79
|
+
(_b = selectRef.current) === null || _b === void 0 ? void 0 : _b.setOpen(false);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
if (isRange === false)
|
|
83
|
+
(_c = selectRef.current) === null || _c === void 0 ? void 0 : _c.setOpen(false);
|
|
84
|
+
onSelectedCustomRange && onSelectedCustomRange(date, null);
|
|
85
|
+
setCurrentMouseHoverDate(date);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
const onMouseEnter = (date) => {
|
|
89
|
+
if (startCustomDate && !endCustomDate) {
|
|
90
|
+
setCurrentMouseHoverDate(date);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
const onMouseLeave = (date) => { };
|
|
94
|
+
const day = new Date(currentYear, currentMonth, 1);
|
|
95
|
+
for (let i = 0; i < day.getDay(); i++) {
|
|
96
|
+
days.push({ type: 'empty', key: `before-${i}` });
|
|
97
|
+
}
|
|
98
|
+
const todayString = new Date().toDateString();
|
|
99
|
+
let firstDate = startCustomDate;
|
|
100
|
+
let secondDate = endCustomDate !== null && endCustomDate !== void 0 ? endCustomDate : currentMouseHoverDate;
|
|
101
|
+
if (firstDate && secondDate && firstDate > secondDate) {
|
|
102
|
+
const temp = firstDate;
|
|
103
|
+
firstDate = secondDate;
|
|
104
|
+
secondDate = temp;
|
|
105
|
+
}
|
|
106
|
+
while (day.getMonth() === currentMonth) {
|
|
107
|
+
const isSelected = (_b = (firstDate && secondDate && day >= firstDate && day <= secondDate)) !== null && _b !== void 0 ? _b : false;
|
|
108
|
+
days.push({
|
|
109
|
+
type: 'day',
|
|
110
|
+
value: day.getDate(),
|
|
111
|
+
today: day.toDateString() === todayString,
|
|
112
|
+
selected: isSelected,
|
|
113
|
+
date: new Date(day),
|
|
114
|
+
isFirstSelected: (_c = (firstDate && firstDate.toDateString() === day.toDateString())) !== null && _c !== void 0 ? _c : false,
|
|
115
|
+
isLastSelected: (_d = (secondDate && secondDate.toDateString() === day.toDateString())) !== null && _d !== void 0 ? _d : false,
|
|
116
|
+
});
|
|
117
|
+
day.setDate(day.getDate() + 1);
|
|
118
|
+
}
|
|
119
|
+
const value = useMemo(() => {
|
|
120
|
+
if (selectedOption !== null)
|
|
121
|
+
return '';
|
|
122
|
+
if (!firstDate && !secondDate)
|
|
123
|
+
return '';
|
|
124
|
+
if (firstDate && !secondDate)
|
|
125
|
+
return firstDate.toLocaleDateString();
|
|
126
|
+
if (secondDate && (firstDate === null || firstDate === void 0 ? void 0 : firstDate.toLocaleDateString()) === secondDate.toLocaleDateString())
|
|
127
|
+
return firstDate.toLocaleDateString();
|
|
128
|
+
if (firstDate && secondDate)
|
|
129
|
+
return `${firstDate.toLocaleDateString()} - ${secondDate.toLocaleDateString()}`;
|
|
130
|
+
return '';
|
|
131
|
+
}, [selectedOption, firstDate, secondDate]);
|
|
132
|
+
placeholder = placeholder !== null && placeholder !== void 0 ? placeholder : 'Selecione um período';
|
|
133
|
+
const { customOptionId, optionComputed } = useMemo(() => {
|
|
134
|
+
if (options && options.length > 0) {
|
|
135
|
+
const customOptionId = Math.max(...options.map(option => { var _a; return (_a = option.id) !== null && _a !== void 0 ? _a : 0; })) + 1;
|
|
136
|
+
const optionComputed = [...options, { text: 'Período Personalizado', id: customOptionId }];
|
|
137
|
+
return { customOptionId, optionComputed };
|
|
138
|
+
}
|
|
139
|
+
return { customOptionId: 0, optionComputed: [] };
|
|
140
|
+
}, [selectedOption, options]);
|
|
141
|
+
return (React.createElement(Select, Object.assign({ ref: selectRef, placeholder: placeholder, label: label, value: value, leftIcon: React.createElement(IconWrapper, { className: "icon", src: calendarSVG, width: "20px", height: "20px", color: theme.colors.shade30 }), options: optionComputed, selectedOption: selectedOption !== null && selectedOption !== void 0 ? selectedOption : (firstDate ? customOptionId : null), onOptionChange: onSelectedOptionChangeHandler }, props),
|
|
142
|
+
React.createElement(CalendarHeader, null,
|
|
143
|
+
React.createElement(IconWrapper, { className: "icon", src: chevronLeftSVG, width: "14px", onClick: () => changeMonth(-1) }),
|
|
144
|
+
monthNames[currentMonth],
|
|
145
|
+
" ",
|
|
146
|
+
currentYear,
|
|
147
|
+
React.createElement(IconWrapper, { className: "icon", src: chevronRightSVG, width: "14px", onClick: () => changeMonth(1) })),
|
|
148
|
+
React.createElement(CalendarGrid, null,
|
|
149
|
+
weekDays.map(weekDay => (React.createElement(CalendarWeekDayLabel, { key: weekDay }, weekDay))),
|
|
150
|
+
days.map(day => {
|
|
151
|
+
if (day.type === 'empty') {
|
|
152
|
+
return React.createElement("div", { key: day.key });
|
|
153
|
+
}
|
|
154
|
+
return (React.createElement(CalendarDay, { isFirstSelected: day.isFirstSelected, isLastSelected: day.isLastSelected, key: day.value, today: day.today, onClick: () => onDayClick(day.date), onMouseEnter: () => onMouseEnter(day.date), onMouseLeave: () => onMouseLeave(day.date) },
|
|
155
|
+
React.createElement(CalendarDaySelectedBackground, { isFirstSelected: day.isFirstSelected, isLastSelected: day.isLastSelected, selected: day.selected, today: day.today }),
|
|
156
|
+
React.createElement(CalendarDayValue, null, day.value)));
|
|
157
|
+
}))));
|
|
158
|
+
};
|
|
159
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/DateRangePicker/index.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAkB,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACnF,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,g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C,EAC1C,YAAY,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC;oBAE1C,oBAAC,6BAA6B,IAC5B,eAAe,EAAE,GAAG,CAAC,eAAe,EACpC,cAAc,EAAE,GAAG,CAAC,cAAc,EAClC,QAAQ,EAAE,GAAG,CAAC,QAAQ,EACtB,KAAK,EAAE,GAAG,CAAC,KAAK,GAChB;oBACF,oBAAC,gBAAgB,QAAE,GAAG,CAAC,KAAK,CAAoB,CACpC,CACf,CAAA;YACH,CAAC,CAAC,CACW,CACR,CACV,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { DateRangePicker } from './index';
|
|
3
|
+
declare const meta: Meta<typeof DateRangePicker>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof DateRangePicker>;
|
|
6
|
+
export declare const SelecionarIntervaloDeDatas: Story;
|
|
7
|
+
export declare const SelecionarIntervaloDeDatasSimples: Story;
|
|
8
|
+
//# sourceMappingURL=stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stories.d.ts","sourceRoot":"","sources":["../../../src/components/DateRangePicker/stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAEjD,OAAO,EAAE,eAAe,EAAwB,MAAM,SAAS,CAAA;AAE/D,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,eAAe,CAeC,CAAA;AAExC,eAAe,IAAI,CAAA;AACnB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,eAAe,CAAC,CAAA;AAsC7C,eAAO,MAAM,0BAA0B,EAAE,KAExC,CAAA;AAED,eAAO,MAAM,iCAAiC,EAAE,KAE/C,CAAA"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import { DateRangePicker } from './index';
|
|
14
|
+
const meta = {
|
|
15
|
+
title: 'Components/DateRangePicker',
|
|
16
|
+
component: DateRangePicker,
|
|
17
|
+
tags: ['autodocs'],
|
|
18
|
+
argTypes: {
|
|
19
|
+
placeholder: { control: 'text' },
|
|
20
|
+
label: { control: 'text' },
|
|
21
|
+
readonly: { control: 'boolean' },
|
|
22
|
+
disabled: { control: 'boolean' },
|
|
23
|
+
selectedOption: { control: 'number' },
|
|
24
|
+
startCustomDate: { control: 'date' },
|
|
25
|
+
endCustomDate: { control: 'date' },
|
|
26
|
+
onSelectedOptionChange: { action: 'selectedOptionChange' },
|
|
27
|
+
onSelectedCustomRange: { action: 'selectedCustomRange' },
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
export default meta;
|
|
31
|
+
const ComponentWrapper = (_a) => {
|
|
32
|
+
var { options } = _a, args = __rest(_a, ["options"]);
|
|
33
|
+
const [selectedOption, setSelectOption] = React.useState(null);
|
|
34
|
+
const [startDate, setStartDate] = React.useState(null);
|
|
35
|
+
const [endDate, setEndDate] = React.useState(null);
|
|
36
|
+
return (React.createElement(DateRangePicker, Object.assign({}, args, { selectedOption: selectedOption, startCustomDate: startDate, endCustomDate: endDate, onSelectedCustomRange: (start, end) => {
|
|
37
|
+
setStartDate(start);
|
|
38
|
+
setEndDate(end);
|
|
39
|
+
}, onSelectedOptionChange: option => setSelectOption(option), options: options !== null && options !== void 0 ? options : [
|
|
40
|
+
{
|
|
41
|
+
text: 'Últimos 30 dias',
|
|
42
|
+
id: 30,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
text: 'Últimos 60 dias',
|
|
46
|
+
id: 60,
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
text: 'Últimos 90 dias',
|
|
50
|
+
id: 90,
|
|
51
|
+
},
|
|
52
|
+
] })));
|
|
53
|
+
};
|
|
54
|
+
export const SelecionarIntervaloDeDatas = {
|
|
55
|
+
render: args => React.createElement(ComponentWrapper, { label: "Per\u00EDodo da Disputa", placeholder: "Placeholder" }),
|
|
56
|
+
};
|
|
57
|
+
export const SelecionarIntervaloDeDatasSimples = {
|
|
58
|
+
render: args => React.createElement(ComponentWrapper, { options: [] }),
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stories.js","sourceRoot":"","sources":["../../../src/components/DateRangePicker/stories.tsx"],"names":[],"mappings":";;;;;;;;;;;AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,eAAe,EAAwB,MAAM,SAAS,CAAA;AAE/D,MAAM,IAAI,GAAiC;IACzC,KAAK,EAAE,4BAA4B;IACnC,SAAS,EAAE,eAAe;IAC1B,IAAI,EAAE,CAAC,UAAU,CAAC;IAClB,QAAQ,EAAE;QACR,WAAW,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE;QAChC,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE;QAC1B,QAAQ,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE;QAChC,QAAQ,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE;QAChC,cAAc,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE;QACrC,eAAe,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE;QACpC,aAAa,EA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AI,CAAC,EAAE,CAAC,oBAAC,gBAAgB,IAAC,KAAK,EAAC,yBAAoB,EAAC,WAAW,EAAC,aAAa,GAAG;CAC1F,CAAA;AAED,MAAM,CAAC,MAAM,iCAAiC,GAAU;IACtD,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,oBAAC,gBAAgB,IAAC,OAAO,EAAE,EAAE,GAAI;CAClD,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const CalendarGrid: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
2
|
+
export declare const CalendarWeekDayLabel: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
3
|
+
export declare const CalendarHeader: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
4
|
+
export interface CalendarDayProps {
|
|
5
|
+
today: boolean;
|
|
6
|
+
isFirstSelected: boolean;
|
|
7
|
+
isLastSelected: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare const CalendarDay: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, CalendarDayProps>> & string;
|
|
10
|
+
export interface CalendarDaySelectedBackgroundProps {
|
|
11
|
+
today: boolean;
|
|
12
|
+
isFirstSelected: boolean;
|
|
13
|
+
isLastSelected: boolean;
|
|
14
|
+
selected: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare const CalendarDaySelectedBackground: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, CalendarDaySelectedBackgroundProps>> & string;
|
|
17
|
+
export declare const CalendarDayValue: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
18
|
+
//# sourceMappingURL=styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/components/DateRangePicker/styles.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,YAAY,6NAYxB,CAAA;AAED,eAAO,MAAM,oBAAoB,6NAKhC,CAAA;AAED,eAAO,MAAM,cAAc,6NAyB1B,CAAA;AACD,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,OAAO,CAAA;IACd,eAAe,EAAE,OAAO,CAAA;IACxB,cAAc,EAAE,OAAO,CAAA;CACxB;AAED,eAAO,MAAM,WAAW,qPAkBvB,CAAA;AAED,MAAM,WAAW,kCAAkC;IACjD,KAAK,EAAE,OAAO,CAAA;IACd,eAAe,EAAE,OAAO,CAAA;IACxB,cAAc,EAAE,OAAO,CAAA;IACvB,QAAQ,EAAE,OAAO,CAAA;CAClB;AACD,eAAO,MAAM,6BAA6B,uQAiCzC,CAAA;AACD,eAAO,MAAM,gBAAgB,6NAO5B,CAAA"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import { theme } from '../Themes';
|
|
3
|
+
export const CalendarGrid = styled.div `
|
|
4
|
+
display: grid;
|
|
5
|
+
font-family: 'Nunito Sans', sans-serif;
|
|
6
|
+
grid-template-columns: repeat(7, 36px);
|
|
7
|
+
align-items: center;
|
|
8
|
+
justify-items: center;
|
|
9
|
+
grid-column-gap: 0px;
|
|
10
|
+
grid-row-gap: 0px;
|
|
11
|
+
height: 100%;
|
|
12
|
+
width: 100%;
|
|
13
|
+
font-size: ${theme.paragraph.small};
|
|
14
|
+
color: ${theme.colors.shade50};
|
|
15
|
+
`;
|
|
16
|
+
export const CalendarWeekDayLabel = styled.div `
|
|
17
|
+
font-size: ${theme.paragraph['xx-small']};
|
|
18
|
+
color: ${theme.colors.shade30};
|
|
19
|
+
font-weight: 600;
|
|
20
|
+
margin-bottom: 4px;
|
|
21
|
+
`;
|
|
22
|
+
export const CalendarHeader = styled.div `
|
|
23
|
+
display: flex;
|
|
24
|
+
justify-content: space-between;
|
|
25
|
+
align-items: center;
|
|
26
|
+
font-size: ${theme.paragraph.small};
|
|
27
|
+
font-family: 'Nunito Sans', sans-serif;
|
|
28
|
+
font-weight: 600;
|
|
29
|
+
|
|
30
|
+
.icon,
|
|
31
|
+
.icon svg,
|
|
32
|
+
.icon svg path {
|
|
33
|
+
fill: ${theme.colors.shade50} !important;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.icon:hover,
|
|
37
|
+
.icon:hover svg,
|
|
38
|
+
.icon:hover svg path {
|
|
39
|
+
fill: ${theme.colors.cyan30} !important;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.icon-disabled,
|
|
43
|
+
.icon-disabled svg,
|
|
44
|
+
.icon-disabled svg path {
|
|
45
|
+
fill: ${theme.colors.shade20} !important;
|
|
46
|
+
}
|
|
47
|
+
`;
|
|
48
|
+
export const CalendarDay = styled.div `
|
|
49
|
+
position: relative;
|
|
50
|
+
cursor: pointer;
|
|
51
|
+
width: 36px;
|
|
52
|
+
height: 36px;
|
|
53
|
+
color: ${({ isFirstSelected, isLastSelected }) => isFirstSelected || isLastSelected ? theme.colors.white : theme.colors.shade50};
|
|
54
|
+
|
|
55
|
+
&:before {
|
|
56
|
+
position: absolute;
|
|
57
|
+
content: '';
|
|
58
|
+
inset: 0;
|
|
59
|
+
border-radius: 50%;
|
|
60
|
+
pointer-events: none;
|
|
61
|
+
|
|
62
|
+
${({ today, isFirstSelected, isLastSelected }) => today && !(isFirstSelected || isLastSelected) ? `border: 1px solid ${theme.colors.cyan40}` : ''};
|
|
63
|
+
}
|
|
64
|
+
`;
|
|
65
|
+
export const CalendarDaySelectedBackground = styled.div `
|
|
66
|
+
position: absolute;
|
|
67
|
+
background-color: ${({ selected }) => selected && theme.colors.cyan30opacity16};
|
|
68
|
+
width: 100%;
|
|
69
|
+
height: 100%;
|
|
70
|
+
inset: 0;
|
|
71
|
+
|
|
72
|
+
border-radius: ${({ isFirstSelected, isLastSelected }) => {
|
|
73
|
+
if (isFirstSelected && isLastSelected)
|
|
74
|
+
return '50%';
|
|
75
|
+
if (isFirstSelected)
|
|
76
|
+
return '50% 0 0 50%';
|
|
77
|
+
if (isLastSelected)
|
|
78
|
+
return '0 50% 50% 0';
|
|
79
|
+
return '0';
|
|
80
|
+
}};
|
|
81
|
+
|
|
82
|
+
&:hover {
|
|
83
|
+
border-radius: ${({ isFirstSelected, isLastSelected, selected }) => {
|
|
84
|
+
if (isFirstSelected && isLastSelected)
|
|
85
|
+
return '50%';
|
|
86
|
+
if (isFirstSelected)
|
|
87
|
+
return '50% 0 0 50%';
|
|
88
|
+
if (isLastSelected)
|
|
89
|
+
return '0 50% 50% 0';
|
|
90
|
+
if (selected)
|
|
91
|
+
return '0';
|
|
92
|
+
return '50%';
|
|
93
|
+
}};
|
|
94
|
+
background-color: ${theme.colors.cyan30opacity16};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
&::before {
|
|
98
|
+
content: '';
|
|
99
|
+
border-radius: 50%;
|
|
100
|
+
background-color: ${({ isFirstSelected, isLastSelected }) => isFirstSelected || isLastSelected ? theme.colors.cyan40 : 'transparent'};
|
|
101
|
+
position: absolute;
|
|
102
|
+
inset: 0;
|
|
103
|
+
}
|
|
104
|
+
`;
|
|
105
|
+
export const CalendarDayValue = styled.div `
|
|
106
|
+
position: absolute;
|
|
107
|
+
inset: 0;
|
|
108
|
+
display: flex;
|
|
109
|
+
align-items: center;
|
|
110
|
+
justify-content: center;
|
|
111
|
+
pointer-events: none;
|
|
112
|
+
`;
|
|
113
|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,CAAC,EAAE;;CAEpG,CAAA;AAQD,MAAM,CAAC,MAAM,6BAA6B,GAAG,MAAM,CAAC,GAAG,CAAoC;;sBAErE,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,QAAQ,IAAI,KAAK,CAAC,MAAM,CAAC,eAAe;;;;;mBAK7D,CAAC,EAAE,eAAe,EAAE,cAAc,EAAE,EAAE,EAAE;IACvD,IAAI,eAAe,IAAI,cAAc;QAAE,OAAO,KAAK,CAAA;IACnD,IAAI,eAAe;QAAE,OAAO,aAAa,CAAA;IACzC,IAAI,cAAc;QAAE,OAAO,aAAa,CAAA;IACxC,OAAO,GAAG,CAAA;AACZ,CAAC;;;qBAGkB,CAAC,EAAE,eAAe,EAAE,cAAc,EAAE,QAAQ,EAAE,EAAE,EAAE;IACjE,IAAI,eAAe,IAAI,cAAc;QAAE,OAAO,KAAK,CAAA;IACnD,IAAI,eAAe;QAAE,OAAO,aAAa,CAAA;IACzC,IAAI,cAAc;QAAE,OAAO,aAAa,CAAA;IACxC,IAAI,QAAQ;QAAE,OAAO,GAAG,CAAA;IACxB,OAAO,KAAK,CAAA;AACd,CAAC;wBACmB,KAAK,CAAC,MAAM,CAAC,eAAe;;;;;;wBAM5B,CAAC,EAAE,eAAe,EAAE,cAAc,EAAE,EAAE,EAAE,CAC1D,eAAe,IAAI,cAAc,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,aAAa;;;;CAI5E,CAAA;AACD,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;CAOzC,CAAA"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React, { HTMLAttributes, ReactNode } from 'react';
|
|
2
2
|
export interface InputProps extends HTMLAttributes<HTMLDivElement> {
|
|
3
3
|
placeholder?: string;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
rightIcon?: ReactNode;
|
|
5
|
+
leftIcon?: ReactNode;
|
|
6
|
+
label?: string;
|
|
6
7
|
value?: string;
|
|
7
8
|
readonly?: boolean;
|
|
8
9
|
disabled?: boolean;
|
|
@@ -10,7 +11,6 @@ export interface InputProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
10
11
|
onInput?: (e: React.FormEvent<HTMLInputElement>) => void;
|
|
11
12
|
onKeyDown?: (e: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
12
13
|
onKeyUp?: (e: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
13
|
-
iconRight?: ReactNode;
|
|
14
14
|
}
|
|
15
15
|
export interface Position {
|
|
16
16
|
x: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Input/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,cAAc,EAAE,SAAS,EAA4B,MAAM,OAAO,CAAA;AAGlF,MAAM,WAAW,UAAW,SAAQ,cAAc,CAAC,cAAc,CAAC;IAChE,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,KAAK,EAAE,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Input/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,cAAc,EAAE,SAAS,EAA4B,MAAM,OAAO,CAAA;AAGlF,MAAM,WAAW,UAAW,SAAQ,cAAc,CAAC,cAAc,CAAC;IAChE,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAA;IAC3D,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAA;IACxD,SAAS,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAA;IAC9D,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAA;CAC7D;AAED,MAAM,WAAW,QAAQ;IACvB,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;CACf;AAED,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,UAAU,CA0FtC,CAAA"}
|
|
@@ -12,7 +12,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
import React, { useEffect, useId, useRef } from 'react';
|
|
13
13
|
import { InputWrapper, StyledInput, StyledInputBorder, StyledInputContent, StyledLabel } from './styles';
|
|
14
14
|
export const Input = (_a) => {
|
|
15
|
-
var { label, readonly, onChange, onInput, value, onKeyDown, disabled, onKeyUp,
|
|
15
|
+
var { label, readonly, onChange, onInput, value, onKeyDown, disabled, onKeyUp, leftIcon, rightIcon } = _a, props = __rest(_a, ["label", "readonly", "onChange", "onInput", "value", "onKeyDown", "disabled", "onKeyUp", "leftIcon", "rightIcon"]);
|
|
16
16
|
const id = useId();
|
|
17
17
|
const [labelPosition, setLabelPosition] = React.useState({
|
|
18
18
|
x: 0,
|
|
@@ -63,8 +63,8 @@ export const Input = (_a) => {
|
|
|
63
63
|
React.createElement(StyledInputContent, { disabled: disabled, ref: contentRef, onClick: onClickHandler },
|
|
64
64
|
React.createElement(StyledInputBorder, { content: contentPosition, label: labelPosition }),
|
|
65
65
|
React.createElement(StyledLabel, { htmlFor: id, ref: labelRef }, label),
|
|
66
|
-
|
|
66
|
+
leftIcon,
|
|
67
67
|
React.createElement(StyledInput, { id: id, disabled: disabled, value: value, placeholder: props.placeholder, ref: inputRef, onChange: onChange, onInput: onInput, onKeyDown: onKeyDown, onKeyUp: onKeyUp, readOnly: readonly }),
|
|
68
|
-
|
|
68
|
+
rightIcon)));
|
|
69
69
|
};
|
|
70
70
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/components/Input/styles.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,GAAG,CAAA;AAEjC,eAAO,MAAM,YAAY,6NAExB,CAAA;AAED,eAAO,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/components/Input/styles.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,GAAG,CAAA;AAEjC,eAAO,MAAM,YAAY,6NAExB,CAAA;AAED,eAAO,MAAM,WAAW,sOA4BvB,CAAA;AAED,eAAO,MAAM,WAAW,sOAavB,CAAA;AAED,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,eAAO,MAAM,kBAAkB,4PAiB9B,CAAA;AAED,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,QAAQ,CAAA;IACf,OAAO,EAAE,QAAQ,CAAA;CAClB;AAED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,2PAa7B,CAAA"}
|