@temp-spotwork/ui 1.4.7 → 1.5.0
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/atoms/avatar/Avatar.stories.js +1 -1
- package/dist/components/atoms/badge/badge.stories.js +1 -1
- package/dist/components/atoms/card-content/label-value-pair/label-value-pair.stories.js +1 -1
- package/dist/components/atoms/form/chips/chips.stories.js +1 -1
- package/dist/components/atoms/form/dropdown-search/dropdown-search.stories.js +1 -1
- package/dist/components/atoms/form/stepper/Stepper.stories.js +1 -1
- package/dist/components/atoms/form/textarea/RichTextarea.stories.d.ts +11 -0
- package/dist/components/atoms/form/textarea/RichTextarea.stories.js +67 -0
- package/dist/components/atoms/form/textarea/Textarea.stories.d.ts +4 -0
- package/dist/components/atoms/form/textarea/Textarea.stories.js +57 -12
- package/dist/components/atoms/form/textarea/index.d.ts +2 -0
- package/dist/components/atoms/form/textarea/index.js +2 -0
- package/dist/components/atoms/form/textarea/rich-textarea.d.ts +53 -0
- package/dist/components/atoms/form/textarea/rich-textarea.js +275 -0
- package/dist/components/atoms/form/textarea/textarea.js +1 -5
- package/dist/components/atoms/form/time-picker/time-picker-dropdown.d.ts +5 -0
- package/dist/components/atoms/form/time-picker/time-picker-dropdown.js +78 -59
- package/dist/components/atoms/form/time-picker/time-picker-input.d.ts +9 -0
- package/dist/components/atoms/form/time-picker/time-picker-input.js +39 -36
- package/dist/components/atoms/form/time-picker/time-picker.d.ts +16 -0
- package/dist/components/atoms/form/time-picker/time-picker.js +39 -33
- package/dist/components/atoms/form/time-picker/time-picker.stories.d.ts +7 -0
- package/dist/components/atoms/form/time-picker/time-picker.stories.js +197 -87
- package/dist/components/atoms/icons/icons.stories.js +1 -1
- package/dist/components/atoms/message/message.stories.js +1 -1
- package/dist/components/atoms/small-large-text/small-large-text.js +3 -2
- package/dist/components/atoms/tab/Tab.stories.js +1 -1
- package/dist/components/molecules/alert/alert.js +3 -2
- package/dist/components/molecules/button/Button.stories.js +1 -1
- package/dist/components/molecules/collapsible-card/Collapsiblecard.stories.js +1 -1
- package/dist/components/molecules/conversation/message-editor/MessageEditor.stories.js +1 -1
- package/dist/components/molecules/conversation/message-group-composer/MessageGroupComposer.stories.js +1 -1
- package/dist/components/molecules/datatables/cell/Cell.stories.js +1 -1
- package/dist/components/molecules/datatables/row/Row.stories.js +1 -1
- package/dist/components/molecules/datatables/row-header/RowHeader.stories.js +1 -1
- package/dist/components/molecules/dataviz/donut-chart/DonutChart.stories.js +1 -1
- package/dist/components/molecules/dataviz/dot-matrix/DotMatrix.stories.js +1 -1
- package/dist/components/molecules/dataviz/single-stacked-bar/SingleStackedBar.stories.js +1 -1
- package/dist/components/molecules/dialog/dialog.d.ts +4 -1
- package/dist/components/molecules/dialog/dialog.js +22 -18
- package/dist/components/molecules/dialog/dialog.stories.d.ts +9 -0
- package/dist/components/molecules/dialog/dialog.stories.js +57 -0
- package/dist/components/molecules/drawer/drawer.js +13 -12
- package/dist/components/molecules/filter/date-selector/DateSelector.stories.d.ts +4 -0
- package/dist/components/molecules/filter/date-selector/DateSelector.stories.js +64 -11
- package/dist/components/molecules/filter/date-selector/date-selector.d.ts +6 -1
- package/dist/components/molecules/filter/date-selector/date-selector.js +75 -68
- package/dist/components/molecules/filter/range-selector/RangeSelector.stories.js +1 -1
- package/dist/components/molecules/form/radiogroup/radiogroup.stories.js +1 -1
- package/dist/components/molecules/link/Link.stories.js +1 -1
- package/dist/components/molecules/navigation/header/Header.stories.js +1 -1
- package/dist/components/molecules/notifications/content/Content.stories.js +1 -1
- package/dist/components/molecules/snackbar/Snackbar.stories.js +1 -1
- package/dist/components/molecules/snackbar/index.js +1 -1
- package/dist/components/molecules/snackbar/snackbar.js +3 -2
- package/dist/components/molecules/tab-group/tabgroup.stories.js +1 -1
- package/dist/{index-DfdAzObv.js → index-CktvVE7I.js} +4 -1
- package/dist/main.d.ts +2 -0
- package/dist/main.js +107 -105
- package/dist/{snackbar-BaF8Ts3S.js → snackbar-CgqDB5xn.js} +5 -4
- package/package.json +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx as r, jsxs as e } from "react/jsx-runtime";
|
|
2
|
-
import { R as
|
|
2
|
+
import { R as $, P as I, O as _, C as j, T as R, D as z } from "../../../index-C0ZrzaoZ.js";
|
|
3
3
|
import "../../styles/tailwind-config/index.js";
|
|
4
|
-
import { Typography as
|
|
4
|
+
import { Typography as D } from "../../styles/typography/typography.js";
|
|
5
5
|
import "../../styles/colors/colors.js";
|
|
6
6
|
import "../../styles/colors/colormap.js";
|
|
7
7
|
import { t as c } from "../../../bundle-mjs-CAy1p0fn.js";
|
|
8
|
-
import { Icons as
|
|
8
|
+
import { Icons as O } from "../../atoms/icons/icons.js";
|
|
9
9
|
import "../../atoms/icons/iconsSVGs/Large/Profile.js";
|
|
10
10
|
import "../../atoms/icons/iconsSVGs/Small/Profile.js";
|
|
11
11
|
import "../../../index-fN7hCOo3.js";
|
|
@@ -19,6 +19,7 @@ import "../../../index-CYyrKZeH.js";
|
|
|
19
19
|
import "../../atoms/form/textfield/textfield.js";
|
|
20
20
|
import "../../atoms/form/stepper/stepper.js";
|
|
21
21
|
import "../../atoms/form/textarea/textarea.js";
|
|
22
|
+
import "../../atoms/form/textarea/rich-textarea.js";
|
|
22
23
|
import "../../atoms/form/timeselect/timeselect.js";
|
|
23
24
|
import { Button as d } from "../button/button.js";
|
|
24
25
|
import "../datatables/cell/cell.js";
|
|
@@ -27,7 +28,7 @@ import "../../../react-spring_web.modern-BLL8Qmtg.js";
|
|
|
27
28
|
import "../form/radiogroup/radiogroup.js";
|
|
28
29
|
import "../../../card-Cc2Qkiqr.js";
|
|
29
30
|
import { useUIElementSize as n } from "./use-ui-element-size.js";
|
|
30
|
-
function
|
|
31
|
+
function sr({
|
|
31
32
|
children: f,
|
|
32
33
|
width: h,
|
|
33
34
|
open: x,
|
|
@@ -38,32 +39,35 @@ function mr({
|
|
|
38
39
|
actionButtons: l,
|
|
39
40
|
hasPadding: g = !0,
|
|
40
41
|
hasActionButtons: o = !0,
|
|
41
|
-
hasBottomBorder: b = !1
|
|
42
|
+
hasBottomBorder: b = !1,
|
|
43
|
+
maxHeight: v,
|
|
44
|
+
contentMaxHeight: y,
|
|
45
|
+
heightSpacingRem: N = 15
|
|
42
46
|
}) {
|
|
43
|
-
const { ref:
|
|
44
|
-
return /* @__PURE__ */ r(
|
|
45
|
-
/* @__PURE__ */ r(
|
|
47
|
+
const { ref: w, height: p } = n(), { ref: C, height: H } = n(), i = N;
|
|
48
|
+
return /* @__PURE__ */ r($, { open: x, onOpenChange: t, children: /* @__PURE__ */ e(I, { children: [
|
|
49
|
+
/* @__PURE__ */ r(_, { className: "fixed inset-0 bg-surface-subduedInverted bg-opacity-50 " }),
|
|
46
50
|
/* @__PURE__ */ e(
|
|
47
|
-
|
|
51
|
+
j,
|
|
48
52
|
{
|
|
49
53
|
className: "fixed top-1/2 left-1/2 max-w-full transform -translate-x-1/2 -translate-y-1/2 rounded-xl bg-surface-default shadow-[0rem_0rem_1rem_0rem_#B0B0B0] focus:outline-none",
|
|
50
|
-
style: { width: h, maxHeight: `calc(100vh - ${i}rem)` },
|
|
54
|
+
style: { width: h, maxHeight: v ?? `calc(100vh - ${i}rem)` },
|
|
51
55
|
children: [
|
|
52
|
-
/* @__PURE__ */ e(
|
|
56
|
+
/* @__PURE__ */ e(R, { className: "p-xl border-b border-bcolor-subdued", ref: w, children: [
|
|
53
57
|
/* @__PURE__ */ e("div", { className: "flex items-start justify-between gap-xxl ", children: [
|
|
54
|
-
/* @__PURE__ */ r(
|
|
55
|
-
/* @__PURE__ */ r(
|
|
58
|
+
/* @__PURE__ */ r(D, { swStyle: 8, children: m }),
|
|
59
|
+
/* @__PURE__ */ r(O, { button: !0, icon: "Cross", handleClick: t })
|
|
56
60
|
] }),
|
|
57
61
|
a && /* @__PURE__ */ r("div", { children: a })
|
|
58
62
|
] }),
|
|
59
|
-
/* @__PURE__ */ r(
|
|
63
|
+
/* @__PURE__ */ r(z, { className: "sr-only", children: m }),
|
|
60
64
|
/* @__PURE__ */ e("div", { children: [
|
|
61
65
|
/* @__PURE__ */ r(
|
|
62
66
|
"div",
|
|
63
67
|
{
|
|
64
68
|
style: {
|
|
65
69
|
// Calculate max height based on viewport height minus spacing and measured header/footer heights
|
|
66
|
-
maxHeight: o ? `calc(100vh - ${i}rem - ${
|
|
70
|
+
maxHeight: y ?? (o ? `calc(100vh - ${i}rem - ${p}px - ${H}px)` : `calc(100vh - ${i}rem - ${p}px)`)
|
|
67
71
|
},
|
|
68
72
|
className: c("overflow-auto", g && "p-xl", !o && "rounded-b-xl"),
|
|
69
73
|
children: f
|
|
@@ -72,7 +76,7 @@ function mr({
|
|
|
72
76
|
o && /* @__PURE__ */ e(
|
|
73
77
|
"div",
|
|
74
78
|
{
|
|
75
|
-
ref:
|
|
79
|
+
ref: C,
|
|
76
80
|
className: c("flex justify-between p-xl", b && "border-t border-bcolor-subdued"),
|
|
77
81
|
children: [
|
|
78
82
|
/* @__PURE__ */ r(
|
|
@@ -85,7 +89,7 @@ function mr({
|
|
|
85
89
|
onClick: t
|
|
86
90
|
}
|
|
87
91
|
),
|
|
88
|
-
l && /* @__PURE__ */ r("div", { className: "flex gap-xl", children: l.map((
|
|
92
|
+
l && /* @__PURE__ */ r("div", { className: "flex gap-xl", children: l.map((s) => /* @__PURE__ */ r(d, { size: "large", ...s }, s.text)) })
|
|
89
93
|
]
|
|
90
94
|
}
|
|
91
95
|
)
|
|
@@ -96,5 +100,5 @@ function mr({
|
|
|
96
100
|
] }) });
|
|
97
101
|
}
|
|
98
102
|
export {
|
|
99
|
-
|
|
103
|
+
sr as Dialog
|
|
100
104
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { Dialog } from './dialog';
|
|
3
|
+
|
|
4
|
+
declare const meta: Meta<typeof Dialog>;
|
|
5
|
+
export default meta;
|
|
6
|
+
type Story = StoryObj<typeof meta>;
|
|
7
|
+
export declare const Default: Story;
|
|
8
|
+
export declare const WithCustomMaxHeight: Story;
|
|
9
|
+
export declare const WithCustomContentMaxHeight: Story;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { w as n, e as i } from "../../../index-CktvVE7I.js";
|
|
3
|
+
import { useState as l } from "react";
|
|
4
|
+
import { Dialog as s } from "./dialog.js";
|
|
5
|
+
const a = (t) => {
|
|
6
|
+
const [o, r] = l(!0);
|
|
7
|
+
return /* @__PURE__ */ e(
|
|
8
|
+
s,
|
|
9
|
+
{
|
|
10
|
+
...t,
|
|
11
|
+
open: o,
|
|
12
|
+
setClose: () => r(!1),
|
|
13
|
+
title: t.title ?? "Dialog Title",
|
|
14
|
+
hasActionButtons: !1,
|
|
15
|
+
children: /* @__PURE__ */ e("div", { className: "h-[60rem]", children: /* @__PURE__ */ e("p", { children: "Dialog content for sizing checks." }) })
|
|
16
|
+
}
|
|
17
|
+
);
|
|
18
|
+
}, p = {
|
|
19
|
+
title: "@spotwork-ui/molecules/Dialog",
|
|
20
|
+
component: s,
|
|
21
|
+
parameters: {
|
|
22
|
+
layout: "centered"
|
|
23
|
+
},
|
|
24
|
+
tags: ["autodocs"],
|
|
25
|
+
args: {
|
|
26
|
+
title: "Dialog Title",
|
|
27
|
+
open: !0,
|
|
28
|
+
setClose: () => {
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}, d = {
|
|
32
|
+
render: (t) => /* @__PURE__ */ e(a, { ...t })
|
|
33
|
+
}, u = {
|
|
34
|
+
render: (t) => /* @__PURE__ */ e(a, { ...t }),
|
|
35
|
+
args: {
|
|
36
|
+
maxHeight: "70vh"
|
|
37
|
+
},
|
|
38
|
+
play: async ({ canvasElement: t }) => {
|
|
39
|
+
const o = n(t.ownerDocument.body).getByRole("dialog");
|
|
40
|
+
await i(o).toHaveStyle({ maxHeight: "70vh" });
|
|
41
|
+
}
|
|
42
|
+
}, y = {
|
|
43
|
+
render: (t) => /* @__PURE__ */ e(a, { ...t }),
|
|
44
|
+
args: {
|
|
45
|
+
contentMaxHeight: "18rem"
|
|
46
|
+
},
|
|
47
|
+
play: async ({ canvasElement: t }) => {
|
|
48
|
+
const o = n(t.ownerDocument.body).getByText("Dialog content for sizing checks.").parentElement;
|
|
49
|
+
await i(o).toHaveStyle({ maxHeight: "18rem" });
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
export {
|
|
53
|
+
d as Default,
|
|
54
|
+
y as WithCustomContentMaxHeight,
|
|
55
|
+
u as WithCustomMaxHeight,
|
|
56
|
+
p as default
|
|
57
|
+
};
|
|
@@ -19,17 +19,18 @@ import "../../../index-CYyrKZeH.js";
|
|
|
19
19
|
import "../../atoms/form/textfield/textfield.js";
|
|
20
20
|
import "../../atoms/form/stepper/stepper.js";
|
|
21
21
|
import "../../atoms/form/textarea/textarea.js";
|
|
22
|
+
import "../../atoms/form/textarea/rich-textarea.js";
|
|
22
23
|
import "../../atoms/form/timeselect/timeselect.js";
|
|
23
24
|
import { Button as L } from "../button/button.js";
|
|
24
25
|
import "../datatables/cell/cell.js";
|
|
25
26
|
import "../dataviz/donut-chart/donut-chart.js";
|
|
26
27
|
import "../form/radiogroup/radiogroup.js";
|
|
27
28
|
import "../../../card-Cc2Qkiqr.js";
|
|
28
|
-
function
|
|
29
|
+
function gr({
|
|
29
30
|
children: N,
|
|
30
31
|
actionBox: b,
|
|
31
32
|
title: l,
|
|
32
|
-
open:
|
|
33
|
+
open: o,
|
|
33
34
|
setOpen: i,
|
|
34
35
|
width: a,
|
|
35
36
|
transitionDuration: c = 500,
|
|
@@ -42,7 +43,7 @@ function vr({
|
|
|
42
43
|
scrollBehavior: D = "auto",
|
|
43
44
|
enableScroll: s = !0
|
|
44
45
|
}) {
|
|
45
|
-
const [n, T] = I(c),
|
|
46
|
+
const [n, T] = I(c), e = y(null), h = y(0), R = X(
|
|
46
47
|
() => ({
|
|
47
48
|
from: { opacity: 0, transform: `translateX(${a})` },
|
|
48
49
|
enter: { opacity: 1, transform: "translateX(0%)" },
|
|
@@ -52,21 +53,21 @@ function vr({
|
|
|
52
53
|
}
|
|
53
54
|
}),
|
|
54
55
|
[a, n]
|
|
55
|
-
), B = E(
|
|
56
|
+
), B = E(o, R);
|
|
56
57
|
v(() => {
|
|
57
58
|
T(c);
|
|
58
59
|
}, [c]);
|
|
59
60
|
const _ = F({
|
|
60
|
-
width:
|
|
61
|
+
width: o ? a : 0,
|
|
61
62
|
config: { duration: n }
|
|
62
63
|
});
|
|
63
64
|
v(() => {
|
|
64
|
-
|
|
65
|
-
}, [
|
|
65
|
+
o && m && s && e.current && (e.current.scrollTop = h.current);
|
|
66
|
+
}, [o, m, s]);
|
|
66
67
|
const $ = () => {
|
|
67
|
-
m && s &&
|
|
68
|
+
m && s && e.current && (h.current = e.current.scrollTop), i == null || i(!1);
|
|
68
69
|
};
|
|
69
|
-
return /* @__PURE__ */ r(M, { open:
|
|
70
|
+
return /* @__PURE__ */ r(M, { open: o, onOpenChange: i, children: /* @__PURE__ */ r(q, { children: B(
|
|
70
71
|
(x, j) => j ? /* @__PURE__ */ t(k, { children: [
|
|
71
72
|
/* @__PURE__ */ r(g.div, { style: { opacity: x.opacity }, children: /* @__PURE__ */ r(
|
|
72
73
|
z,
|
|
@@ -105,10 +106,10 @@ function vr({
|
|
|
105
106
|
u && /* @__PURE__ */ r("div", { children: /* @__PURE__ */ r(L, { ...u }) })
|
|
106
107
|
] })
|
|
107
108
|
] }),
|
|
108
|
-
|
|
109
|
+
o && /* @__PURE__ */ r(
|
|
109
110
|
"div",
|
|
110
111
|
{
|
|
111
|
-
ref:
|
|
112
|
+
ref: e,
|
|
112
113
|
className: `flex-1 ${s ? "overflow-y-auto overflow-x-hidden" : "overflow-hidden"}`,
|
|
113
114
|
style: { scrollBehavior: D },
|
|
114
115
|
children: N
|
|
@@ -122,5 +123,5 @@ function vr({
|
|
|
122
123
|
) }) });
|
|
123
124
|
}
|
|
124
125
|
export {
|
|
125
|
-
|
|
126
|
+
gr as Drawer
|
|
126
127
|
};
|
|
@@ -5,3 +5,7 @@ declare const meta: Meta<typeof DateSelector>;
|
|
|
5
5
|
export default meta;
|
|
6
6
|
type Story = StoryObj<typeof meta>;
|
|
7
7
|
export declare const Primary: Story;
|
|
8
|
+
export declare const CalendarOpensBottom: Story;
|
|
9
|
+
export declare const CalendarOpensTop: Story;
|
|
10
|
+
export declare const CalendarOpensLeft: Story;
|
|
11
|
+
export declare const CalendarOpensRight: Story;
|
|
@@ -1,20 +1,73 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { jsx as c } from "react/jsx-runtime";
|
|
2
|
+
import { w as o, u as r, e as s } from "../../../../index-CktvVE7I.js";
|
|
3
|
+
import { useState as i } from "react";
|
|
4
|
+
import { DateSelector as d } from "./date-selector.js";
|
|
5
|
+
const n = (e) => {
|
|
6
|
+
const [t, a] = i(/* @__PURE__ */ new Date());
|
|
7
|
+
return /* @__PURE__ */ c(d, { ...e, value: t, onChange: (l) => a(l) });
|
|
8
|
+
}, w = {
|
|
4
9
|
title: "@spotwork-ui/DateSelector",
|
|
5
|
-
component:
|
|
10
|
+
component: d,
|
|
6
11
|
parameters: {
|
|
7
12
|
layout: "centered"
|
|
8
13
|
},
|
|
9
14
|
tags: ["autodocs"],
|
|
10
|
-
|
|
11
|
-
|
|
15
|
+
args: {
|
|
16
|
+
mode: "day",
|
|
17
|
+
weekStartsAt: 0
|
|
18
|
+
}
|
|
19
|
+
}, u = {
|
|
20
|
+
render: (e) => /* @__PURE__ */ c(n, { ...e })
|
|
21
|
+
}, C = {
|
|
22
|
+
render: (e) => /* @__PURE__ */ c(n, { ...e }),
|
|
23
|
+
args: {
|
|
24
|
+
calendarPlacement: "bottom"
|
|
12
25
|
},
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
26
|
+
play: async ({ canvasElement: e }) => {
|
|
27
|
+
const t = o(e);
|
|
28
|
+
await r.click(t.getByTestId("date-selected"));
|
|
29
|
+
const a = o(e.ownerDocument.body).getByTestId("date-selector-calendar");
|
|
30
|
+
await s(a.className).toContain("top-[3rem]");
|
|
31
|
+
}
|
|
32
|
+
}, B = {
|
|
33
|
+
render: (e) => /* @__PURE__ */ c(n, { ...e }),
|
|
34
|
+
args: {
|
|
35
|
+
calendarPlacement: "top"
|
|
36
|
+
},
|
|
37
|
+
play: async ({ canvasElement: e }) => {
|
|
38
|
+
const t = o(e);
|
|
39
|
+
await r.click(t.getByTestId("date-selected"));
|
|
40
|
+
const a = o(e.ownerDocument.body).getByTestId("date-selector-calendar");
|
|
41
|
+
await s(a.className).toContain("bottom-[3rem]");
|
|
42
|
+
}
|
|
43
|
+
}, T = {
|
|
44
|
+
render: (e) => /* @__PURE__ */ c(n, { ...e }),
|
|
45
|
+
args: {
|
|
46
|
+
calendarPlacement: "left"
|
|
47
|
+
},
|
|
48
|
+
play: async ({ canvasElement: e }) => {
|
|
49
|
+
const t = o(e);
|
|
50
|
+
await r.click(t.getByTestId("date-selected"));
|
|
51
|
+
const a = o(e.ownerDocument.body).getByTestId("date-selector-calendar");
|
|
52
|
+
await s(a.className).toContain("right-[calc(100%+0.5rem)]");
|
|
53
|
+
}
|
|
54
|
+
}, f = {
|
|
55
|
+
render: (e) => /* @__PURE__ */ c(n, { ...e }),
|
|
56
|
+
args: {
|
|
57
|
+
calendarPlacement: "right"
|
|
58
|
+
},
|
|
59
|
+
play: async ({ canvasElement: e }) => {
|
|
60
|
+
const t = o(e);
|
|
61
|
+
await r.click(t.getByTestId("date-selected"));
|
|
62
|
+
const a = o(e.ownerDocument.body).getByTestId("date-selector-calendar");
|
|
63
|
+
await s(a.className).toContain("left-[calc(100%+0.5rem)]");
|
|
64
|
+
}
|
|
16
65
|
};
|
|
17
66
|
export {
|
|
18
|
-
|
|
19
|
-
|
|
67
|
+
C as CalendarOpensBottom,
|
|
68
|
+
T as CalendarOpensLeft,
|
|
69
|
+
f as CalendarOpensRight,
|
|
70
|
+
B as CalendarOpensTop,
|
|
71
|
+
u as Primary,
|
|
72
|
+
w as default
|
|
20
73
|
};
|
|
@@ -26,6 +26,11 @@ export type DateSelectorProps = {
|
|
|
26
26
|
* optional autoFocus
|
|
27
27
|
*/
|
|
28
28
|
autoFocus?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Controls where the calendar dropdown opens relative to the trigger button.
|
|
31
|
+
* @default 'bottom'
|
|
32
|
+
*/
|
|
33
|
+
calendarPlacement?: 'top' | 'bottom' | 'left' | 'right';
|
|
29
34
|
};
|
|
30
|
-
export declare function DateSelector({ mode, weekStartsAt, value, onChange, autoFocus, }: DateSelectorProps): import("react/jsx-runtime").JSX.Element;
|
|
35
|
+
export declare function DateSelector({ mode, weekStartsAt, value, onChange, autoFocus, calendarPlacement, }: DateSelectorProps): import("react/jsx-runtime").JSX.Element;
|
|
31
36
|
export {};
|
|
@@ -3,25 +3,26 @@ import m from "react";
|
|
|
3
3
|
import { Icons as g } from "../../../atoms/icons/icons.js";
|
|
4
4
|
import "../../../atoms/icons/iconsSVGs/Large/Profile.js";
|
|
5
5
|
import "../../../atoms/icons/iconsSVGs/Small/Profile.js";
|
|
6
|
-
import { Button as
|
|
6
|
+
import { Button as lt } from "../../button/button.js";
|
|
7
7
|
import "../../../styles/colors/colors.js";
|
|
8
|
-
import { surface as
|
|
9
|
-
import { outlinedBorder as
|
|
8
|
+
import { surface as o } from "../../../styles/colors/colormap.js";
|
|
9
|
+
import { outlinedBorder as dt } from "../../../styles/defaults/defaults.js";
|
|
10
10
|
import { Typography as p } from "../../../styles/typography/typography.js";
|
|
11
11
|
import { c as x } from "../../../../index-fN7hCOo3.js";
|
|
12
|
-
import { formatDateToMonthYear as N, endOfMonth as v, parseShortMonthYear as u, formatShortMonthYear as
|
|
13
|
-
import { p as
|
|
14
|
-
import { f as
|
|
15
|
-
import { s as
|
|
16
|
-
import { s as
|
|
17
|
-
function
|
|
12
|
+
import { formatDateToMonthYear as N, endOfMonth as v, parseShortMonthYear as u, formatShortMonthYear as mt, isSameMonth as P, isSameWeek as D } from "../../../atoms/form/dateselect/helpers.js";
|
|
13
|
+
import { p as ft, e as Y, s as ht, a as ut, b as yt, i as O, c as k } from "../../../../isToday-DmBTkQMq.js";
|
|
14
|
+
import { f as s, g as Mt, a as w } from "../../../../format-BwmhcciO.js";
|
|
15
|
+
import { s as gt } from "../../../../startOfToday-BPMZZniU.js";
|
|
16
|
+
import { s as pt, a as f } from "../../../../startOfWeek-DBvLd9He.js";
|
|
17
|
+
function Pt({
|
|
18
18
|
mode: y = "day",
|
|
19
|
-
weekStartsAt:
|
|
19
|
+
weekStartsAt: a = 0,
|
|
20
20
|
value: r,
|
|
21
21
|
onChange: l,
|
|
22
|
-
autoFocus:
|
|
22
|
+
autoFocus: E = !1,
|
|
23
|
+
calendarPlacement: F = "bottom"
|
|
23
24
|
}) {
|
|
24
|
-
const $ = m.useRef(null),
|
|
25
|
+
const $ = m.useRef(null), H = m.useRef(null), S = gt(), [_, W] = m.useState(!1), z = () => {
|
|
25
26
|
W((t) => !t);
|
|
26
27
|
};
|
|
27
28
|
m.useEffect(() => {
|
|
@@ -33,18 +34,18 @@ function Gt({
|
|
|
33
34
|
document.removeEventListener("click", t);
|
|
34
35
|
};
|
|
35
36
|
}, []);
|
|
36
|
-
const [c, d] = m.useState(() => r && Array.isArray(r) ? N(new Date(r[0])) : r ? N(new Date(r)) : N(S)),
|
|
37
|
-
const t =
|
|
38
|
-
d(
|
|
39
|
-
},
|
|
40
|
-
const t =
|
|
41
|
-
d(
|
|
42
|
-
}, C = ["S", "M", "T", "W", "T", "F", "S"],
|
|
37
|
+
const [c, d] = m.useState(() => r && Array.isArray(r) ? N(new Date(r[0])) : r ? N(new Date(r)) : N(S)), q = () => y === "day" ? O(S, r) ? "Today" : s(r, "dd MMM") : s(r[0], "dd MMM") + "–" + s(r[1], "dd MMM"), J = () => {
|
|
38
|
+
const t = w(h, { months: -1 });
|
|
39
|
+
d(s(t, "MMM-yyyy"));
|
|
40
|
+
}, K = () => {
|
|
41
|
+
const t = w(h, { months: 1 });
|
|
42
|
+
d(s(t, "MMM-yyyy"));
|
|
43
|
+
}, C = ["S", "M", "T", "W", "T", "F", "S"], Q = C.slice(a).concat(C.slice(0, a)), U = () => /* @__PURE__ */ M("div", { className: "flex items-center w-full justify-between h-[3rem]", children: [
|
|
43
44
|
/* @__PURE__ */ n(
|
|
44
45
|
g,
|
|
45
46
|
{
|
|
46
47
|
disabled: !1,
|
|
47
|
-
handleClick:
|
|
48
|
+
handleClick: J,
|
|
48
49
|
icon: "ChevronLeftSmall",
|
|
49
50
|
color: "active",
|
|
50
51
|
button: !0,
|
|
@@ -56,7 +57,7 @@ function Gt({
|
|
|
56
57
|
{
|
|
57
58
|
swStyle: 1,
|
|
58
59
|
color: "active",
|
|
59
|
-
children: `${
|
|
60
|
+
children: `${mt(c)}`,
|
|
60
61
|
className: "min-w-[2rem] text-center"
|
|
61
62
|
}
|
|
62
63
|
),
|
|
@@ -64,14 +65,14 @@ function Gt({
|
|
|
64
65
|
g,
|
|
65
66
|
{
|
|
66
67
|
disabled: !1,
|
|
67
|
-
handleClick:
|
|
68
|
+
handleClick: K,
|
|
68
69
|
icon: "ChevronRightSmall",
|
|
69
70
|
color: "active",
|
|
70
71
|
button: !0,
|
|
71
72
|
id: "next-month"
|
|
72
73
|
}
|
|
73
74
|
)
|
|
74
|
-
] }),
|
|
75
|
+
] }), V = () => /* @__PURE__ */ n("div", { className: "flex justify-center items-center gap-[1rem] bg-[#e7e7e7] rounded-[0.5rem] w-full h-[2rem]", children: Q.map((t, e) => /* @__PURE__ */ n(
|
|
75
76
|
p,
|
|
76
77
|
{
|
|
77
78
|
swStyle: 1,
|
|
@@ -80,23 +81,23 @@ function Gt({
|
|
|
80
81
|
className: "min-w-[2rem] text-center"
|
|
81
82
|
},
|
|
82
83
|
t + e
|
|
83
|
-
)) }), h =
|
|
84
|
+
)) }), h = ft(c, "MMM-yyyy", /* @__PURE__ */ new Date()), j = Y({
|
|
84
85
|
start: h,
|
|
85
86
|
end: v(h)
|
|
86
|
-
}),
|
|
87
|
-
j.unshift(...new Array(
|
|
88
|
-
const
|
|
87
|
+
}), X = (h.getDay() - a + 7) % 7;
|
|
88
|
+
j.unshift(...new Array(X).fill(null));
|
|
89
|
+
const Z = () => {
|
|
89
90
|
const t = f(r, -1);
|
|
90
|
-
d(
|
|
91
|
-
},
|
|
91
|
+
d(s(t, "MMM-yyyy")), l(t);
|
|
92
|
+
}, A = () => {
|
|
92
93
|
const t = f(r, 1);
|
|
93
|
-
d(
|
|
94
|
-
},
|
|
94
|
+
d(s(t, "MMM-yyyy")), l(t);
|
|
95
|
+
}, tt = () => /* @__PURE__ */ n("div", { className: "flex flex-row flex-wrap gap-md justify-start items-start", children: j.map((t, e) => t === null ? /* @__PURE__ */ n("div", { className: "w-[2rem] h-[2rem]" }, `null-${e}`) : /* @__PURE__ */ n(
|
|
95
96
|
"div",
|
|
96
97
|
{
|
|
97
98
|
className: x(
|
|
98
99
|
"cursor-pointer rounded w-[2rem] h-[2rem] hover:bg-surface-active",
|
|
99
|
-
|
|
100
|
+
k(t) && "border border-bcolor-subdued rounded",
|
|
100
101
|
O(new Date(t), r) && "bg-surface-active border-bcolor-active"
|
|
101
102
|
),
|
|
102
103
|
onClick: () => l(t),
|
|
@@ -111,37 +112,37 @@ function Gt({
|
|
|
111
112
|
)
|
|
112
113
|
},
|
|
113
114
|
t.getDate()
|
|
114
|
-
)) }), [T, B] = m.useState(),
|
|
115
|
+
)) }), [T, B] = m.useState(), et = () => {
|
|
115
116
|
const t = f(r[0], 7), e = f(r[1], 7);
|
|
116
|
-
d(
|
|
117
|
-
},
|
|
117
|
+
d(s(t, "MMM-yyyy")), l([t, e]);
|
|
118
|
+
}, rt = () => {
|
|
118
119
|
const t = f(r[0], -7), e = f(r[1], -7);
|
|
119
|
-
d(
|
|
120
|
+
d(s(t, "MMM-yyyy")), l([t, e]);
|
|
120
121
|
};
|
|
121
|
-
function
|
|
122
|
-
const e =
|
|
123
|
-
return
|
|
122
|
+
function nt(t) {
|
|
123
|
+
const e = ht(u(t)), i = v(u(t));
|
|
124
|
+
return ut(
|
|
124
125
|
{
|
|
125
126
|
start: e,
|
|
126
127
|
end: i
|
|
127
128
|
},
|
|
128
|
-
{ weekStartsOn:
|
|
129
|
-
).map((b) =>
|
|
130
|
-
start:
|
|
131
|
-
end:
|
|
129
|
+
{ weekStartsOn: a }
|
|
130
|
+
).map((b) => Y({
|
|
131
|
+
start: pt(b, { weekStartsOn: a }),
|
|
132
|
+
end: yt(b, { weekStartsOn: a })
|
|
132
133
|
}));
|
|
133
134
|
}
|
|
134
|
-
const
|
|
135
|
+
const at = nt(c), R = (t) => {
|
|
135
136
|
const e = 0.07142857142857142;
|
|
136
137
|
if (t[t.length - 1].getMonth() > u(c).getMonth() || t[t.length - 1].getFullYear() > u(c).getFullYear()) {
|
|
137
|
-
const L = v(t[0]).getDay() -
|
|
138
|
-
return `linear-gradient(to right, ${
|
|
138
|
+
const L = v(t[0]).getDay() - a, ct = (L / t.length + e) * 100, it = ((L + 1) / t.length + e) * 100;
|
|
139
|
+
return `linear-gradient(to right, ${o.active} 0%, ${o.active} ${ct}%, ${o.default} ${it}%, ${o.default} 100%)`;
|
|
139
140
|
}
|
|
140
141
|
if (t[0].getMonth() === u(c).getMonth())
|
|
141
|
-
return
|
|
142
|
-
const i = v(t[0]).getDay() -
|
|
143
|
-
return `linear-gradient(to right, ${
|
|
144
|
-
},
|
|
142
|
+
return o.active;
|
|
143
|
+
const i = v(t[0]).getDay() - a, I = (i / t.length + e) * 100, G = ((i + 1) / t.length + e) * 100;
|
|
144
|
+
return `linear-gradient(to right, ${o.default} 0%, ${o.default} ${I}%, ${o.active} ${G}%, ${o.active} 100%)`;
|
|
145
|
+
}, ot = () => /* @__PURE__ */ n("div", { className: "flex flex-col gap-md", children: at.map((t) => /* @__PURE__ */ n(
|
|
145
146
|
"div",
|
|
146
147
|
{
|
|
147
148
|
className: x(
|
|
@@ -158,20 +159,20 @@ function Gt({
|
|
|
158
159
|
onMouseEnter: () => B(t),
|
|
159
160
|
onMouseLeave: () => B(void 0),
|
|
160
161
|
onClick: () => l([t[0], t[t.length - 1]]),
|
|
161
|
-
children: t.map((e) =>
|
|
162
|
+
children: t.map((e) => P(c, e) ? /* @__PURE__ */ n(
|
|
162
163
|
"div",
|
|
163
164
|
{
|
|
164
165
|
className: x(
|
|
165
166
|
"cursor-pointer rounded w-[2rem] h-[2rem]",
|
|
166
|
-
|
|
167
|
+
k(e) && "border border-bcolor-subdued rounded",
|
|
167
168
|
D(e, r[0]) && "border-bcolor-active"
|
|
168
169
|
),
|
|
169
170
|
children: /* @__PURE__ */ n(
|
|
170
171
|
p,
|
|
171
172
|
{
|
|
172
173
|
swStyle: 1,
|
|
173
|
-
color: D(e, r[0],
|
|
174
|
-
children:
|
|
174
|
+
color: D(e, r[0], a) ? "active" : "default",
|
|
175
|
+
children: P(c, e) ? e.getDate() : "",
|
|
175
176
|
className: "min-w-[2rem] text-center"
|
|
176
177
|
}
|
|
177
178
|
)
|
|
@@ -179,8 +180,13 @@ function Gt({
|
|
|
179
180
|
e.getDate()
|
|
180
181
|
) : /* @__PURE__ */ n("div", { className: "w-[2rem] h-[2rem]" }, e.getDate()))
|
|
181
182
|
},
|
|
182
|
-
`week-${
|
|
183
|
-
)) })
|
|
183
|
+
`week-${Mt(t[0])}`
|
|
184
|
+
)) }), st = {
|
|
185
|
+
top: "bottom-[3rem] right-0",
|
|
186
|
+
bottom: "top-[3rem] right-0",
|
|
187
|
+
left: "top-0 right-[calc(100%+0.5rem)]",
|
|
188
|
+
right: "top-0 left-[calc(100%+0.5rem)]"
|
|
189
|
+
};
|
|
184
190
|
return /* @__PURE__ */ M(
|
|
185
191
|
"div",
|
|
186
192
|
{
|
|
@@ -191,34 +197,35 @@ function Gt({
|
|
|
191
197
|
g,
|
|
192
198
|
{
|
|
193
199
|
disabled: !1,
|
|
194
|
-
handleClick: () => y === "day" ?
|
|
200
|
+
handleClick: () => y === "day" ? Z() : rt(),
|
|
195
201
|
icon: "ChevronLeftSmall",
|
|
196
202
|
color: "active",
|
|
197
203
|
button: !0,
|
|
198
204
|
id: "prev-period"
|
|
199
205
|
}
|
|
200
206
|
),
|
|
201
|
-
/* @__PURE__ */ M("div", { className: "relative", id: "custom", ref:
|
|
207
|
+
/* @__PURE__ */ M("div", { className: "relative", id: "custom", ref: H, children: [
|
|
202
208
|
/* @__PURE__ */ n(
|
|
203
|
-
|
|
209
|
+
lt,
|
|
204
210
|
{
|
|
205
|
-
autoFocus:
|
|
211
|
+
autoFocus: E,
|
|
206
212
|
"data-testid": "date-selected",
|
|
207
213
|
size: "small",
|
|
208
214
|
variant: "tertiary",
|
|
209
215
|
color: "affirmative",
|
|
210
|
-
text:
|
|
211
|
-
onClick:
|
|
216
|
+
text: q(),
|
|
217
|
+
onClick: z
|
|
212
218
|
}
|
|
213
219
|
),
|
|
214
|
-
|
|
220
|
+
_ && /* @__PURE__ */ n(
|
|
215
221
|
"div",
|
|
216
222
|
{
|
|
217
|
-
|
|
223
|
+
"data-testid": "date-selector-calendar",
|
|
224
|
+
className: `absolute z-[25] bg-surface-default ${dt.active} p-md ${st[F]}`,
|
|
218
225
|
children: /* @__PURE__ */ M("div", { className: "flex flex-col justify-center items-center gap-md", children: [
|
|
219
|
-
Q(),
|
|
220
226
|
U(),
|
|
221
|
-
|
|
227
|
+
V(),
|
|
228
|
+
/* @__PURE__ */ n("div", { className: "flex flex-col gap-md", children: y === "day" ? tt() : ot() })
|
|
222
229
|
] })
|
|
223
230
|
}
|
|
224
231
|
)
|
|
@@ -227,7 +234,7 @@ function Gt({
|
|
|
227
234
|
g,
|
|
228
235
|
{
|
|
229
236
|
disabled: !1,
|
|
230
|
-
handleClick: () => y === "day" ?
|
|
237
|
+
handleClick: () => y === "day" ? A() : et(),
|
|
231
238
|
icon: "ChevronRightSmall",
|
|
232
239
|
color: "active",
|
|
233
240
|
button: !0,
|
|
@@ -239,5 +246,5 @@ function Gt({
|
|
|
239
246
|
);
|
|
240
247
|
}
|
|
241
248
|
export {
|
|
242
|
-
|
|
249
|
+
Pt as DateSelector
|
|
243
250
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as o } from "react/jsx-runtime";
|
|
2
|
-
import { f as t } from "../../../../index-
|
|
2
|
+
import { f as t } from "../../../../index-CktvVE7I.js";
|
|
3
3
|
import { Radiogroup as s } from "./radiogroup.js";
|
|
4
4
|
import { useState as d } from "react";
|
|
5
5
|
import { Icons as r } from "../../../atoms/icons/icons.js";
|