@fluidattacks/design 11.10.0 → 11.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.
- package/dist/components/inputs/fields/combobox/field/index.js +164 -160
- package/dist/components/inputs/fields/combobox/index.stories.d.ts +3 -1
- package/dist/components/inputs/fields/combobox/option/index.d.ts +1 -1
- package/dist/components/inputs/fields/combobox/option/index.js +103 -87
- package/dist/components/inputs/fields/combobox/styles.js +44 -26
- package/dist/components/inputs/fields/combobox/types.d.ts +6 -1
- package/dist/components/inputs/fields/month/index.d.ts +5 -0
- package/dist/components/inputs/fields/month/index.js +81 -0
- package/dist/components/inputs/fields/month/index.stories.d.ts +7 -0
- package/dist/components/inputs/fields/month/index.test.d.ts +1 -0
- package/dist/components/inputs/fields/month/panel.js +104 -0
- package/dist/components/inputs/fields/month/styles.d.ts +3 -1
- package/dist/components/inputs/fields/month/styles.js +109 -0
- package/dist/components/inputs/fields/month/types.d.ts +11 -0
- package/dist/components/inputs/fields/month/utils.js +34 -0
- package/dist/components/inputs/index.d.ts +2 -1
- package/dist/components/inputs/index.js +14 -12
- package/dist/index.js +232 -230
- package/package.json +1 -1
|
@@ -1,137 +1,153 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { useOption as
|
|
4
|
-
import { useTheme as
|
|
5
|
-
import { StyledOption as
|
|
6
|
-
import { describeSelection as
|
|
7
|
-
import { Checkbox as
|
|
8
|
-
import { Icon as
|
|
9
|
-
import { Link as
|
|
10
|
-
import { Tag as
|
|
1
|
+
import { jsxs as D, Fragment as X, jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as Y, useMemo as f, useCallback as k } from "react";
|
|
3
|
+
import { useOption as Z } from "../../../../../node_modules/react-aria/dist/private/listbox/useOption.js";
|
|
4
|
+
import { useTheme as _ } from "styled-components";
|
|
5
|
+
import { StyledOption as I } from "../styles.js";
|
|
6
|
+
import { describeSelection as V, toSelection as F } from "../utils.js";
|
|
7
|
+
import { Checkbox as w } from "../../../../checkbox/index.js";
|
|
8
|
+
import { Icon as N } from "../../../../icon/index.js";
|
|
9
|
+
import { Link as oo } from "../../../../link/index.js";
|
|
10
|
+
import { Tag as eo } from "../../../../tag/index.js";
|
|
11
11
|
import "../../../../typography/heading/index.js";
|
|
12
12
|
import "../../../../typography/span/index.js";
|
|
13
|
-
import { Text as
|
|
14
|
-
import { useClickOutside as
|
|
15
|
-
import { openUrl as
|
|
16
|
-
const
|
|
17
|
-
allItemKeys:
|
|
18
|
-
containerRef:
|
|
19
|
-
countLabel:
|
|
13
|
+
import { Text as ro } from "../../../../typography/text/index.js";
|
|
14
|
+
import { useClickOutside as to } from "../../../../../hooks/use-click-outside.js";
|
|
15
|
+
import { openUrl as io } from "../../../../../utils/open-url.js";
|
|
16
|
+
const bo = ({
|
|
17
|
+
allItemKeys: g,
|
|
18
|
+
containerRef: q,
|
|
19
|
+
countLabel: O,
|
|
20
|
+
icon: $,
|
|
20
21
|
item: o,
|
|
21
22
|
multiSelection: s,
|
|
22
23
|
name: e,
|
|
23
|
-
popoverRef:
|
|
24
|
-
setInputValue:
|
|
25
|
-
setValue:
|
|
26
|
-
state:
|
|
27
|
-
tag:
|
|
24
|
+
popoverRef: B,
|
|
25
|
+
setInputValue: c,
|
|
26
|
+
setValue: t,
|
|
27
|
+
state: i,
|
|
28
|
+
tag: A,
|
|
28
29
|
watch: h
|
|
29
30
|
}) => {
|
|
30
|
-
const
|
|
31
|
-
(r) => !Array.from(
|
|
32
|
-
), { optionProps:
|
|
31
|
+
const K = _(), b = Y(null), d = o.props.hrefLang, y = i.disabledKeys, m = g.filter(
|
|
32
|
+
(r) => !Array.from(y).includes(r) && r !== "All"
|
|
33
|
+
), { optionProps: M, isSelected: v, isFocused: P, isDisabled: p } = Z(
|
|
33
34
|
{ key: o.key },
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
),
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
].join(" "),
|
|
35
|
+
i,
|
|
36
|
+
b
|
|
37
|
+
), x = f(() => i.collection.getItem("All")?.rendered?.toString(), [i.collection]), R = [
|
|
38
|
+
v ? "selected" : "",
|
|
39
|
+
P ? "focused" : "",
|
|
40
|
+
p ? "disabled" : ""
|
|
41
|
+
].join(" "), S = k(
|
|
41
42
|
(r) => {
|
|
42
|
-
const { allSelected:
|
|
43
|
+
const { allSelected: l, text: a } = V(
|
|
43
44
|
r,
|
|
44
|
-
a,
|
|
45
45
|
g,
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
y,
|
|
47
|
+
x,
|
|
48
|
+
O
|
|
48
49
|
);
|
|
49
|
-
|
|
50
|
+
t?.(`${e}CheckAll`, l ? a : ""), c(a);
|
|
50
51
|
},
|
|
51
52
|
[
|
|
52
|
-
a,
|
|
53
|
-
b,
|
|
54
|
-
$,
|
|
55
53
|
g,
|
|
54
|
+
x,
|
|
55
|
+
O,
|
|
56
|
+
y,
|
|
56
57
|
e,
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
c,
|
|
59
|
+
t
|
|
59
60
|
]
|
|
60
|
-
),
|
|
61
|
+
), U = k(
|
|
61
62
|
(r) => {
|
|
62
63
|
if (r.target.checked) {
|
|
63
|
-
const
|
|
64
|
-
|
|
64
|
+
const l = [...m].sort();
|
|
65
|
+
t?.(`${e}Options`, l), t?.(`${e}CheckAll`, r.target.value), c(r.target.value);
|
|
65
66
|
} else
|
|
66
|
-
|
|
67
|
+
t?.(`${e}Options`, []), t?.(`${e}CheckAll`, ""), c("");
|
|
67
68
|
},
|
|
68
|
-
[
|
|
69
|
-
),
|
|
69
|
+
[m, e, c, t]
|
|
70
|
+
), E = k(
|
|
70
71
|
(r) => {
|
|
71
|
-
const
|
|
72
|
-
|
|
72
|
+
const l = r.target.value, a = F(h?.(`${e}Options`)), z = r.target.checked ? [...a, l] : a.filter((W) => W !== l);
|
|
73
|
+
t?.(`${e}Options`, z), S(z);
|
|
73
74
|
},
|
|
74
|
-
[e,
|
|
75
|
-
),
|
|
76
|
-
() => u
|
|
77
|
-
[
|
|
78
|
-
),
|
|
79
|
-
() =>
|
|
80
|
-
[
|
|
81
|
-
),
|
|
82
|
-
|
|
75
|
+
[e, t, h, S]
|
|
76
|
+
), u = h?.(`${e}Options`), L = f(
|
|
77
|
+
() => F(u),
|
|
78
|
+
[u]
|
|
79
|
+
), G = f(
|
|
80
|
+
() => L.includes(o.key.toString()),
|
|
81
|
+
[L, o.key]
|
|
82
|
+
), T = h?.(`${e}CheckAll`), H = f(() => !!T, [T]), C = /* @__PURE__ */ D(X, { children: [
|
|
83
|
+
$ === void 0 ? void 0 : /* @__PURE__ */ n(
|
|
84
|
+
N,
|
|
85
|
+
{
|
|
86
|
+
icon: $,
|
|
87
|
+
iconSize: "lg",
|
|
88
|
+
iconType: "fa-light",
|
|
89
|
+
spanClass: "option-icon"
|
|
90
|
+
}
|
|
91
|
+
),
|
|
92
|
+
/* @__PURE__ */ n("span", { className: "option-name", children: o.rendered })
|
|
93
|
+
] }), J = o.key === "All" ? /* @__PURE__ */ n(
|
|
94
|
+
w,
|
|
83
95
|
{
|
|
84
|
-
checked:
|
|
85
|
-
|
|
96
|
+
checked: H,
|
|
97
|
+
"data-testid": o.textValue,
|
|
98
|
+
disabled: p,
|
|
99
|
+
label: C,
|
|
86
100
|
name: `${e}CheckAll`,
|
|
87
|
-
onChange:
|
|
101
|
+
onChange: U,
|
|
88
102
|
value: o.rendered?.toString()
|
|
89
103
|
}
|
|
90
|
-
) : /* @__PURE__ */
|
|
91
|
-
|
|
104
|
+
) : /* @__PURE__ */ n(
|
|
105
|
+
w,
|
|
92
106
|
{
|
|
93
|
-
checked:
|
|
94
|
-
|
|
107
|
+
checked: G,
|
|
108
|
+
"data-testid": o.textValue,
|
|
109
|
+
disabled: p,
|
|
110
|
+
label: C,
|
|
95
111
|
name: `${e}Options`,
|
|
96
|
-
onChange:
|
|
112
|
+
onChange: E,
|
|
97
113
|
value: o.key.toString()
|
|
98
114
|
}
|
|
99
|
-
),
|
|
100
|
-
|
|
115
|
+
), j = s ? J : /* @__PURE__ */ n(
|
|
116
|
+
ro,
|
|
101
117
|
{
|
|
102
|
-
color:
|
|
118
|
+
color: K.palette.gray[800],
|
|
103
119
|
size: "md",
|
|
104
120
|
textOverflow: "ellipsis",
|
|
105
121
|
whiteSpace: "nowrap",
|
|
106
|
-
children:
|
|
122
|
+
children: C
|
|
107
123
|
}
|
|
108
|
-
),
|
|
124
|
+
), Q = k(
|
|
109
125
|
(r) => {
|
|
110
|
-
r.preventDefault(),
|
|
111
|
-
|
|
112
|
-
}),
|
|
126
|
+
r.preventDefault(), c(o.rendered?.toString() ?? ""), i.setSelectedKey(o.key), requestAnimationFrame(() => {
|
|
127
|
+
i.setOpen(!1);
|
|
128
|
+
}), io(d);
|
|
113
129
|
},
|
|
114
|
-
[d, o.key, o.rendered,
|
|
130
|
+
[d, o.key, o.rendered, i, c]
|
|
115
131
|
);
|
|
116
|
-
return
|
|
117
|
-
s &&
|
|
118
|
-
}, [
|
|
119
|
-
|
|
132
|
+
return to(B, () => {
|
|
133
|
+
s && i.close();
|
|
134
|
+
}, [q]), /* @__PURE__ */ D(
|
|
135
|
+
I,
|
|
120
136
|
{
|
|
121
|
-
...!s && !d ?
|
|
137
|
+
...!s && !d ? M : {},
|
|
122
138
|
$multiSelection: s,
|
|
123
|
-
className:
|
|
139
|
+
className: R,
|
|
124
140
|
"data-testid": `${e}-option-${o.key}`,
|
|
125
|
-
ref:
|
|
141
|
+
ref: b,
|
|
126
142
|
title: o.textValue,
|
|
127
143
|
children: [
|
|
128
|
-
d ? /* @__PURE__ */
|
|
129
|
-
|
|
130
|
-
|
|
144
|
+
d && !p ? /* @__PURE__ */ n(oo, { href: d, onClick: Q, children: j }) : j,
|
|
145
|
+
v && !p && !s ? /* @__PURE__ */ n(N, { icon: "check", iconSize: "sm", iconType: "fa-light" }) : void 0,
|
|
146
|
+
A === void 0 ? void 0 : /* @__PURE__ */ n(eo, { tagLabel: A, variant: "inactive" })
|
|
131
147
|
]
|
|
132
148
|
}
|
|
133
149
|
);
|
|
134
150
|
};
|
|
135
151
|
export {
|
|
136
|
-
|
|
152
|
+
bo as Option
|
|
137
153
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { styled as
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { styled as n } from "styled-components";
|
|
2
|
+
import { LabelText as l } from "../../../checkbox/styles.js";
|
|
3
|
+
import { StyledIconButton as t } from "../../../icon-button/styles.js";
|
|
4
|
+
const d = n.ul`
|
|
5
|
+
${({ theme: a, $hasStatus: o, $multiSelection: p, $width: i }) => `
|
|
5
6
|
align-self: center;
|
|
6
7
|
background: ${a.palette.white};
|
|
7
8
|
border: 1px solid ${a.palette.gray[200]};
|
|
@@ -11,7 +12,7 @@ const t = o.ul`
|
|
|
11
12
|
max-height: 200px;
|
|
12
13
|
min-width: ${i < 240 ? i : 240}px;
|
|
13
14
|
overflow: hidden auto;
|
|
14
|
-
padding: ${a.spacing[0.25]} 0 ${
|
|
15
|
+
padding: ${a.spacing[0.25]} 0 ${o ? "0" : a.spacing[0.25]} 0;
|
|
15
16
|
scrollbar-color: ${a.palette.gray[600]} ${a.palette.gray[100]};
|
|
16
17
|
scroll-padding: ${a.spacing[0.5]};
|
|
17
18
|
width: 95%;
|
|
@@ -20,8 +21,8 @@ const t = o.ul`
|
|
|
20
21
|
border-bottom: ${p ? `1px solid ${a.palette.gray[200]}` : "unset"};
|
|
21
22
|
}
|
|
22
23
|
`}
|
|
23
|
-
`,
|
|
24
|
-
${({ theme: a, $multiSelection:
|
|
24
|
+
`, g = n.li`
|
|
25
|
+
${({ theme: a, $multiSelection: o }) => `
|
|
25
26
|
align-items: center;
|
|
26
27
|
background: ${a.palette.white};
|
|
27
28
|
color: ${a.palette.gray[800]};
|
|
@@ -30,12 +31,12 @@ const t = o.ul`
|
|
|
30
31
|
gap: ${a.spacing[0.5]};
|
|
31
32
|
justify-content: space-between;
|
|
32
33
|
line-height: ${a.spacing[1.25]};
|
|
33
|
-
padding: ${
|
|
34
|
+
padding: ${o ? `${a.spacing[0.125]} ${a.spacing[0.75]}` : `${a.spacing[0.25]} ${a.spacing[1]}`};
|
|
34
35
|
|
|
35
36
|
a, p, label {
|
|
36
37
|
display: inline-flex;
|
|
37
38
|
overflow: hidden;
|
|
38
|
-
padding: ${
|
|
39
|
+
padding: ${o ? a.spacing[0.25] : "0"};
|
|
39
40
|
width: 100%;
|
|
40
41
|
}
|
|
41
42
|
|
|
@@ -53,24 +54,41 @@ const t = o.ul`
|
|
|
53
54
|
color: ${a.palette.gray[700]};
|
|
54
55
|
}
|
|
55
56
|
|
|
57
|
+
.option-icon {
|
|
58
|
+
color: ${a.palette.gray[800]};
|
|
59
|
+
margin-right: ${a.spacing[0.5]};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.option-name {
|
|
63
|
+
color: ${a.palette.gray[800]};
|
|
64
|
+
}
|
|
65
|
+
|
|
56
66
|
&:hover:not(.disabled, .selected) {
|
|
57
|
-
background: ${a.palette.gray[
|
|
67
|
+
background: ${a.palette.gray[50]};
|
|
58
68
|
}
|
|
59
69
|
|
|
60
70
|
&.selected {
|
|
61
|
-
background: ${
|
|
71
|
+
background: ${o ? a.palette.white : a.palette.gray[100]};
|
|
62
72
|
}
|
|
63
73
|
|
|
64
74
|
&.disabled {
|
|
65
|
-
background: ${a.palette.gray[100]};
|
|
66
75
|
cursor: not-allowed;
|
|
67
76
|
|
|
68
|
-
|
|
69
|
-
|
|
77
|
+
input:disabled ~ ${l} {
|
|
78
|
+
opacity: 1;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.option-icon {
|
|
82
|
+
opacity: 0.4;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.option-name {
|
|
86
|
+
color: ${a.palette.gray[600]};
|
|
87
|
+
opacity: 0.5;
|
|
70
88
|
}
|
|
71
89
|
}
|
|
72
90
|
`}
|
|
73
|
-
`,
|
|
91
|
+
`, e = n.li`
|
|
74
92
|
${({ theme: a }) => `
|
|
75
93
|
align-items: center;
|
|
76
94
|
color: ${a.palette.gray[400]};
|
|
@@ -81,13 +99,13 @@ const t = o.ul`
|
|
|
81
99
|
padding: ${a.spacing[0.25]} ${a.spacing[1]};
|
|
82
100
|
size: 28;
|
|
83
101
|
`}
|
|
84
|
-
`,
|
|
85
|
-
${({ disabled: a, theme:
|
|
102
|
+
`, $ = n(t)`
|
|
103
|
+
${({ disabled: a, theme: o }) => `
|
|
86
104
|
position: relative;
|
|
87
105
|
|
|
88
106
|
& .chevron-down span,
|
|
89
107
|
& .chevron-up span {
|
|
90
|
-
${a ? `color: ${
|
|
108
|
+
${a ? `color: ${o.palette.gray[300]};` : ""}
|
|
91
109
|
}
|
|
92
110
|
|
|
93
111
|
/* CLOSE STATE */
|
|
@@ -104,7 +122,7 @@ const t = o.ul`
|
|
|
104
122
|
display: none;
|
|
105
123
|
}
|
|
106
124
|
`}
|
|
107
|
-
`,
|
|
125
|
+
`, y = n.li`
|
|
108
126
|
${({ theme: a }) => `
|
|
109
127
|
border-top: 1px solid ${a.palette.gray[200]};
|
|
110
128
|
color: ${a.palette.gray[400]};
|
|
@@ -116,7 +134,7 @@ const t = o.ul`
|
|
|
116
134
|
padding: ${a.spacing[0.25]} ${a.spacing[1]};
|
|
117
135
|
user-select: none;
|
|
118
136
|
`}
|
|
119
|
-
`,
|
|
137
|
+
`, b = n.li`
|
|
120
138
|
${({ theme: a }) => `
|
|
121
139
|
background: ${a.palette.white};
|
|
122
140
|
border-top: 1px solid ${a.palette.gray[200]};
|
|
@@ -130,10 +148,10 @@ const t = o.ul`
|
|
|
130
148
|
`}
|
|
131
149
|
`;
|
|
132
150
|
export {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
151
|
+
$ as ChevronIconButton,
|
|
152
|
+
d as StyledDropdown,
|
|
153
|
+
e as StyledEmptyMessage,
|
|
154
|
+
y as StyledGroupHeader,
|
|
155
|
+
g as StyledOption,
|
|
156
|
+
b as StyledStatusMessage
|
|
139
157
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IconName } from '@fortawesome/free-solid-svg-icons';
|
|
1
2
|
import { Key, Node } from '@react-types/shared';
|
|
2
3
|
import { InputHTMLAttributes, MutableRefObject } from 'react';
|
|
3
4
|
import { Control, UseFormSetValue, UseFormWatch } from 'react-hook-form';
|
|
@@ -8,13 +9,15 @@ import { IOutlineContainerProps } from '../../types';
|
|
|
8
9
|
* @interface IItem
|
|
9
10
|
* @property { string } [group] - Optional group header for the item.
|
|
10
11
|
* @property { string } [href] - The href of the item.
|
|
12
|
+
* @property { IconName } [icon] - Optional icon shown before the name.
|
|
11
13
|
* @property { string } name - The name of the item.
|
|
12
|
-
* @property { string } [tag] - Optional tag of the item.
|
|
14
|
+
* @property { string } [tag] - Optional tag shown at the end of the item.
|
|
13
15
|
* @property { string } value - The value of the item.
|
|
14
16
|
*/
|
|
15
17
|
interface IItem {
|
|
16
18
|
group?: string;
|
|
17
19
|
href?: string;
|
|
20
|
+
icon?: IconName;
|
|
18
21
|
name: string;
|
|
19
22
|
tag?: string;
|
|
20
23
|
value: string;
|
|
@@ -24,6 +27,7 @@ interface IItem {
|
|
|
24
27
|
* @interface IOptionProps
|
|
25
28
|
* @property { MutableRefObject } containerRef - The ref of the ComboBox container.
|
|
26
29
|
* @property { string } [countLabel] - Plural noun of the selection summary.
|
|
30
|
+
* @property { IconName } [icon] - Optional icon shown before the name.
|
|
27
31
|
* @property { IItem } item - The item to be rendered as an option.
|
|
28
32
|
* @property { boolean } multiSelection - Enable to select more than one option.
|
|
29
33
|
* @property { string } name - The name of the Select.
|
|
@@ -35,6 +39,7 @@ interface IOptionProps<T> {
|
|
|
35
39
|
allItemKeys: string[];
|
|
36
40
|
containerRef: MutableRefObject<HTMLDivElement | null>;
|
|
37
41
|
countLabel?: string;
|
|
42
|
+
icon?: IconName;
|
|
38
43
|
item: Node<IItem>;
|
|
39
44
|
multiSelection: boolean;
|
|
40
45
|
name: string;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { IMonthPickerProps } from './types';
|
|
2
|
+
/** A month and year selector over `MM/YYYY` values; months outside the bounds are disabled. */
|
|
3
|
+
declare const MonthPicker: ({ disabled, label, maxValue, minValue, name, onChange, value, }: Readonly<IMonthPickerProps>) => JSX.Element;
|
|
4
|
+
export { MonthPicker };
|
|
5
|
+
export type { IMonthPickerProps };
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { jsxs as f, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as $, useCallback as x } from "react";
|
|
3
|
+
import { useButton as y } from "../../../../node_modules/react-aria/dist/private/button/useButton.js";
|
|
4
|
+
import { useOverlayTrigger as T } from "../../../../node_modules/react-aria/dist/private/overlays/useOverlayTrigger.js";
|
|
5
|
+
import { useOverlayTriggerState as v } from "../../../../node_modules/react-stately/dist/private/overlays/useOverlayTriggerState.js";
|
|
6
|
+
import { MonthPanel as O } from "./panel.js";
|
|
7
|
+
import { TriggerButton as S, PeriodText as C } from "./styles.js";
|
|
8
|
+
import { formatPeriod as j } from "./utils.js";
|
|
9
|
+
import { OutlineContainer as k } from "../../outline-container/index.js";
|
|
10
|
+
import { Dialog as z } from "../../utils/dialog/index.js";
|
|
11
|
+
import { Popover as B } from "../../utils/popover/index.js";
|
|
12
|
+
import { theme as D } from "../../../colors/index.js";
|
|
13
|
+
import { Icon as p } from "../../../icon/index.js";
|
|
14
|
+
const N = ({
|
|
15
|
+
disabled: t = !1,
|
|
16
|
+
label: n,
|
|
17
|
+
maxValue: a,
|
|
18
|
+
minValue: g,
|
|
19
|
+
name: i,
|
|
20
|
+
onChange: s,
|
|
21
|
+
value: l
|
|
22
|
+
}) => {
|
|
23
|
+
const e = $(null), r = v({}), { close: c } = r, { triggerProps: d, overlayProps: h } = T(
|
|
24
|
+
{ type: "dialog" },
|
|
25
|
+
r,
|
|
26
|
+
e
|
|
27
|
+
), { buttonProps: u } = y(
|
|
28
|
+
{ ...d, isDisabled: t, onPress: r.toggle },
|
|
29
|
+
e
|
|
30
|
+
), b = x(
|
|
31
|
+
(P) => {
|
|
32
|
+
s(P), c();
|
|
33
|
+
},
|
|
34
|
+
[c, s]
|
|
35
|
+
), m = D.palette.gray[t ? 400 : 700];
|
|
36
|
+
return /* @__PURE__ */ f(k, { htmlFor: i, label: n, children: [
|
|
37
|
+
/* @__PURE__ */ f(S, { ...u, id: i, ref: e, children: [
|
|
38
|
+
/* @__PURE__ */ o(
|
|
39
|
+
p,
|
|
40
|
+
{
|
|
41
|
+
icon: "calendar",
|
|
42
|
+
iconColor: m,
|
|
43
|
+
iconSize: "lg",
|
|
44
|
+
iconType: "fa-light"
|
|
45
|
+
}
|
|
46
|
+
),
|
|
47
|
+
/* @__PURE__ */ o(C, { children: j(l) }),
|
|
48
|
+
/* @__PURE__ */ o(
|
|
49
|
+
p,
|
|
50
|
+
{
|
|
51
|
+
icon: "chevron-down",
|
|
52
|
+
iconColor: m,
|
|
53
|
+
iconSize: "sm",
|
|
54
|
+
iconType: "fa-light"
|
|
55
|
+
}
|
|
56
|
+
)
|
|
57
|
+
] }),
|
|
58
|
+
r.isOpen && !t ? /* @__PURE__ */ o(
|
|
59
|
+
B,
|
|
60
|
+
{
|
|
61
|
+
offset: 8,
|
|
62
|
+
placement: "bottom end",
|
|
63
|
+
state: r,
|
|
64
|
+
triggerRef: e,
|
|
65
|
+
children: /* @__PURE__ */ o(z, { ...h, "aria-label": n ?? i, children: /* @__PURE__ */ o(
|
|
66
|
+
O,
|
|
67
|
+
{
|
|
68
|
+
maxValue: a,
|
|
69
|
+
minValue: g,
|
|
70
|
+
onClose: c,
|
|
71
|
+
onSelect: b,
|
|
72
|
+
value: l
|
|
73
|
+
}
|
|
74
|
+
) })
|
|
75
|
+
}
|
|
76
|
+
) : null
|
|
77
|
+
] });
|
|
78
|
+
};
|
|
79
|
+
export {
|
|
80
|
+
N as MonthPicker
|
|
81
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Meta } from '@storybook/react-vite';
|
|
2
|
+
import { IMonthPickerProps } from './types';
|
|
3
|
+
declare const config: Meta;
|
|
4
|
+
declare const Default: import('storybook/internal/csf').AnnotatedStoryFn<import('@storybook/react').ReactRenderer, IMonthPickerProps>;
|
|
5
|
+
declare const WithBounds: import('storybook/internal/csf').AnnotatedStoryFn<import('@storybook/react').ReactRenderer, IMonthPickerProps>;
|
|
6
|
+
export { Default, WithBounds };
|
|
7
|
+
export default config;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { jsxs as p, Fragment as C, jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { useState as O, useCallback as l } from "react";
|
|
3
|
+
import { YearBar as b, MonthGrid as F, Footer as w, MonthItem as x } from "./styles.js";
|
|
4
|
+
import { fromPeriod as M, toPeriod as y, isOutOfRange as d, MONTHS as T } from "./utils.js";
|
|
5
|
+
import { Button as f } from "../../../button/index.js";
|
|
6
|
+
import { IconButton as m } from "../../../icon-button/index.js";
|
|
7
|
+
const D = 0, B = 11, v = (t) => t === void 0 ? void 0 : M(t)?.year, H = (t, e, r) => Math.min(Math.max(t, v(e) ?? t), v(r) ?? t), I = ({
|
|
8
|
+
disabled: t,
|
|
9
|
+
month: e,
|
|
10
|
+
onSelect: r,
|
|
11
|
+
selected: a,
|
|
12
|
+
year: s
|
|
13
|
+
}) => {
|
|
14
|
+
const c = l(() => {
|
|
15
|
+
r(y(s, e));
|
|
16
|
+
}, [e, r, s]);
|
|
17
|
+
return /* @__PURE__ */ n(
|
|
18
|
+
x,
|
|
19
|
+
{
|
|
20
|
+
"aria-pressed": a,
|
|
21
|
+
disabled: t,
|
|
22
|
+
onClick: c,
|
|
23
|
+
type: "button",
|
|
24
|
+
children: T[e]
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
}, R = ({
|
|
28
|
+
maxValue: t,
|
|
29
|
+
minValue: e,
|
|
30
|
+
onClose: r,
|
|
31
|
+
onSelect: a,
|
|
32
|
+
value: s
|
|
33
|
+
}) => {
|
|
34
|
+
const c = M(s), [i, g] = O(
|
|
35
|
+
H(c?.year ?? (/* @__PURE__ */ new Date()).getFullYear(), e, t)
|
|
36
|
+
), Y = l(() => {
|
|
37
|
+
g((o) => o - 1);
|
|
38
|
+
}, []), k = l(() => {
|
|
39
|
+
g((o) => o + 1);
|
|
40
|
+
}, []), u = l(() => {
|
|
41
|
+
const o = /* @__PURE__ */ new Date();
|
|
42
|
+
a(y(o.getFullYear(), o.getMonth()));
|
|
43
|
+
}, [a]);
|
|
44
|
+
return /* @__PURE__ */ p(C, { children: [
|
|
45
|
+
/* @__PURE__ */ p(b, { children: [
|
|
46
|
+
/* @__PURE__ */ n(
|
|
47
|
+
m,
|
|
48
|
+
{
|
|
49
|
+
disabled: d(i - 1, B, e, void 0),
|
|
50
|
+
icon: "chevron-left",
|
|
51
|
+
iconSize: "sm",
|
|
52
|
+
iconType: "fa-light",
|
|
53
|
+
id: "previous-year",
|
|
54
|
+
onClick: Y,
|
|
55
|
+
variant: "ghost"
|
|
56
|
+
}
|
|
57
|
+
),
|
|
58
|
+
/* @__PURE__ */ n("span", { children: i }),
|
|
59
|
+
/* @__PURE__ */ n(
|
|
60
|
+
m,
|
|
61
|
+
{
|
|
62
|
+
disabled: d(i + 1, D, void 0, t),
|
|
63
|
+
icon: "chevron-right",
|
|
64
|
+
iconSize: "sm",
|
|
65
|
+
iconType: "fa-light",
|
|
66
|
+
id: "next-year",
|
|
67
|
+
onClick: k,
|
|
68
|
+
variant: "ghost"
|
|
69
|
+
}
|
|
70
|
+
)
|
|
71
|
+
] }),
|
|
72
|
+
/* @__PURE__ */ n(F, { children: T.map((o, h) => /* @__PURE__ */ n(
|
|
73
|
+
I,
|
|
74
|
+
{
|
|
75
|
+
disabled: d(i, h, e, t),
|
|
76
|
+
month: h,
|
|
77
|
+
onSelect: a,
|
|
78
|
+
selected: c?.year === i && c.month === h,
|
|
79
|
+
year: i
|
|
80
|
+
},
|
|
81
|
+
o
|
|
82
|
+
)) }),
|
|
83
|
+
/* @__PURE__ */ p(w, { children: [
|
|
84
|
+
/* @__PURE__ */ n(
|
|
85
|
+
f,
|
|
86
|
+
{
|
|
87
|
+
disabled: d(
|
|
88
|
+
(/* @__PURE__ */ new Date()).getFullYear(),
|
|
89
|
+
(/* @__PURE__ */ new Date()).getMonth(),
|
|
90
|
+
e,
|
|
91
|
+
t
|
|
92
|
+
),
|
|
93
|
+
onClick: u,
|
|
94
|
+
variant: "textLink",
|
|
95
|
+
children: "Today"
|
|
96
|
+
}
|
|
97
|
+
),
|
|
98
|
+
/* @__PURE__ */ n(f, { onClick: r, variant: "ghost", children: "Cancel" })
|
|
99
|
+
] })
|
|
100
|
+
] });
|
|
101
|
+
};
|
|
102
|
+
export {
|
|
103
|
+
R as MonthPanel
|
|
104
|
+
};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
declare const TriggerButton: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<import('react').DetailedHTMLProps<import('react').ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, never> & Partial<Pick<import('react').DetailedHTMLProps<import('react').ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, never>>> & string;
|
|
2
|
+
declare const PeriodText: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never> & Partial<Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never>>> & string;
|
|
1
3
|
declare const YearBar: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never> & Partial<Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>> & string;
|
|
2
4
|
declare const MonthGrid: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never> & Partial<Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>> & string;
|
|
3
5
|
declare const MonthItem: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<import('react').DetailedHTMLProps<import('react').ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, never> & Partial<Pick<import('react').DetailedHTMLProps<import('react').ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, never>>> & string;
|
|
4
6
|
declare const Footer: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never> & Partial<Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>> & string;
|
|
5
|
-
export { Footer, MonthGrid, MonthItem, YearBar };
|
|
7
|
+
export { Footer, MonthGrid, MonthItem, PeriodText, TriggerButton, YearBar };
|