triafly-ui-kit 1.0.25 → 1.0.27

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.
Files changed (37) hide show
  1. package/README.md +93 -93
  2. package/dist/_virtual/dayjs.min.js +7 -0
  3. package/dist/_virtual/dayjs.min2.js +4 -0
  4. package/dist/_virtual/ru.js +2 -0
  5. package/dist/_virtual/ru2.js +4 -0
  6. package/dist/assets/src/components/Ui/DateRangePicker/DateRangePicker.css +1 -0
  7. package/dist/assets/src/components/Ui/Tooltip/Tooltip.stories.module.css +1 -1
  8. package/dist/components/Ui/DatePicker/DatePicker.js +6 -13
  9. package/dist/components/Ui/DatePicker/DatePicker.stories.js +33 -39
  10. package/dist/components/Ui/DatePicker/index.js +4 -0
  11. package/dist/components/Ui/DateRangePicker/DateRangePicker.js +195 -0
  12. package/dist/components/Ui/DateRangePicker/DateRangePicker.stories.js +84 -0
  13. package/dist/components/Ui/DateRangePicker/const.js +37 -0
  14. package/dist/components/Ui/DateRangePicker/hooks/useCalendarRenderer.js +48 -0
  15. package/dist/components/Ui/DateRangePicker/hooks/useChangeDate.js +28 -0
  16. package/dist/components/Ui/DateRangePicker/hooks/useDateNavigation.js +22 -0
  17. package/dist/components/Ui/DateRangePicker/hooks/useDateRangeState.js +24 -0
  18. package/dist/components/Ui/DateRangePicker/hooks/useQuickRange.js +77 -0
  19. package/dist/components/Ui/DateRangePicker/index.js +4 -0
  20. package/dist/main.d.ts +33 -0
  21. package/dist/main.js +157 -153
  22. package/dist/node_modules/dayjs/dayjs.min.js +282 -0
  23. package/dist/node_modules/dayjs/locale/ru.js +36 -0
  24. package/dist/src/components/Ui/Tooltip/Tooltip.stories.module.css.js +1 -1
  25. package/dist/styles/_mixins.scss +21 -21
  26. package/dist/styles/fix.scss +3 -3
  27. package/dist/styles/main.scss +26 -26
  28. package/dist/styles/reset.scss +105 -105
  29. package/dist/styles/typography.scss +102 -102
  30. package/dist/styles/variables.scss +273 -278
  31. package/package.json +111 -110
  32. package/src/styles/_mixins.scss +21 -21
  33. package/src/styles/fix.scss +3 -3
  34. package/src/styles/main.scss +26 -26
  35. package/src/styles/reset.scss +105 -105
  36. package/src/styles/typography.scss +102 -102
  37. package/src/styles/variables.scss +273 -278
@@ -0,0 +1,84 @@
1
+ import { jsx as i } from "react/jsx-runtime";
2
+ import { DateRangePicker as a } from "./DateRangePicker.js";
3
+ import e from "../../../_virtual/dayjs.min.js";
4
+ const s = {
5
+ title: "UIKit/DateRangePicker",
6
+ component: a,
7
+ tags: ["autodocs"],
8
+ argTypes: {
9
+ disabledBefore: {
10
+ control: "text",
11
+ description: "Дизейбл до"
12
+ },
13
+ disabledAfter: {
14
+ control: "text",
15
+ description: "Дизейбл после"
16
+ },
17
+ className: {
18
+ control: "text",
19
+ description: "Класс для основного контейнера"
20
+ },
21
+ onChange: {
22
+ action: "dateChanged",
23
+ description: "Обработчик изменения даты"
24
+ },
25
+ placeholder: {
26
+ control: "text",
27
+ description: "Текст плейсхолдера"
28
+ },
29
+ autoCompleteWithToday: {
30
+ control: "boolean",
31
+ description: "Автозаполнение датой, если указали один не полностью"
32
+ },
33
+ initialRange: {
34
+ control: "object",
35
+ description: "Начальное состояние"
36
+ }
37
+ }
38
+ }, d = {
39
+ args: {
40
+ placeholder: "Любая дата"
41
+ }
42
+ }, c = {
43
+ args: {
44
+ initialRange: {
45
+ start: e("2023-01-01"),
46
+ end: e()
47
+ },
48
+ placeholder: "Выберите дату"
49
+ }
50
+ }, p = {
51
+ args: {
52
+ disabledBefore: e(new Date(2023, 0, 1)),
53
+ disabledAfter: e(new Date(2023, 11, 31)),
54
+ placeholder: "Выберите дату в 2023 году"
55
+ }
56
+ }, g = {
57
+ args: {
58
+ disabledAfter: e(),
59
+ placeholder: "Выберите дату"
60
+ }
61
+ }, h = {
62
+ args: {
63
+ initialRange: {
64
+ start: e("2025-06-01"),
65
+ end: e("2025-06-15")
66
+ },
67
+ placeholder: "Выберите дату"
68
+ },
69
+ render: (t) => {
70
+ const o = {
71
+ ...t,
72
+ initialRange: t.initialRange
73
+ };
74
+ return /* @__PURE__ */ i(a, { ...o });
75
+ }
76
+ };
77
+ export {
78
+ d as Default,
79
+ h as InitialDate,
80
+ p as WithDateRange,
81
+ g as WithDateRangeDisabledMonth,
82
+ c as WithInitialDate,
83
+ s as default
84
+ };
@@ -0,0 +1,37 @@
1
+ const e = [
2
+ {
3
+ label: "Сегодня",
4
+ key: "today"
5
+ },
6
+ {
7
+ label: "Вчера",
8
+ key: "yesterday"
9
+ },
10
+ {
11
+ label: "Эта неделя",
12
+ key: "thisWeek"
13
+ },
14
+ {
15
+ label: "Прошлая неделя",
16
+ key: "lastWeek"
17
+ },
18
+ {
19
+ label: "Этот месяц",
20
+ key: "thisMonth"
21
+ },
22
+ {
23
+ label: "Прошлый месяц",
24
+ key: "lastMonth"
25
+ },
26
+ {
27
+ label: "Этот год",
28
+ key: "thisYear"
29
+ },
30
+ {
31
+ label: "Прошлый год",
32
+ key: "lastYear"
33
+ }
34
+ ];
35
+ export {
36
+ e as selectAutoCompliteDate
37
+ };
@@ -0,0 +1,48 @@
1
+ import { jsx as n, jsxs as u } from "react/jsx-runtime";
2
+ import D from "../../../../_virtual/dayjs.min.js";
3
+ const B = (o, S, d, i) => {
4
+ const $ = D();
5
+ return { renderCalendar: (a, C) => {
6
+ const e = a.startOf("month"), c = a.endOf("month"), O = c.date(), M = (e.day() + 6) % 7, r = [];
7
+ for (let t = M; t > 0; t--)
8
+ r.push(e.subtract(t, "day"));
9
+ for (let t = 0; t < O; t++)
10
+ r.push(e.add(t, "day"));
11
+ const N = Math.ceil(r.length / 7) * 7 - r.length;
12
+ for (let t = 1; t <= N; t++)
13
+ r.push(c.add(t, "day"));
14
+ const l = [];
15
+ for (let t = 0; t < r.length; t += 7)
16
+ l.push(r.slice(t, t + 7));
17
+ return /* @__PURE__ */ n("div", { className: "calendar-month", children: /* @__PURE__ */ u("table", { children: [
18
+ /* @__PURE__ */ n("thead", { children: /* @__PURE__ */ n("tr", { children: ["Пн", "Вт", "Ср", "Чт", "Пт", "Сб", "Вс"].map((t) => /* @__PURE__ */ n("th", { children: t }, t)) }) }),
19
+ /* @__PURE__ */ n("tbody", { children: l.map((t, h) => /* @__PURE__ */ n("tr", { children: t.map((s, b) => {
20
+ var f, p;
21
+ if (!s || s.month() !== a.month())
22
+ return /* @__PURE__ */ n("td", { className: "other-month empty" }, `empty-${h}-${b}`);
23
+ const y = d && s.isBefore(d, "day") || i && s.isAfter(i, "day"), m = s.isSame($, "day"), j = (f = o.start) == null ? void 0 : f.isSame(s, "day"), k = (p = o.end) == null ? void 0 : p.isSame(s, "day"), v = o.start && o.end && s.isAfter(o.start, "day") && s.isBefore(o.end, "day");
24
+ return /* @__PURE__ */ u(
25
+ "td",
26
+ {
27
+ className: `
28
+ ${y ? "disabled" : ""}
29
+ ${m ? "today" : ""}
30
+ ${j ? "selected-start" : ""}
31
+ ${k ? "selected-end" : ""}
32
+ ${v ? "in-range" : ""}
33
+ `,
34
+ onClick: () => !y && S(s, C),
35
+ children: [
36
+ s.date(),
37
+ m && /* @__PURE__ */ n("div", { className: "today-dot" })
38
+ ]
39
+ },
40
+ s.toString()
41
+ );
42
+ }) }, h)) })
43
+ ] }) });
44
+ } };
45
+ };
46
+ export {
47
+ B as useCalendarRenderer
48
+ };
@@ -0,0 +1,28 @@
1
+ import p from "../../../../_virtual/dayjs.min.js";
2
+ const j = (r, o, m, f, k, D, B, O, y, h, i) => ({ handleDateClick: (t, a) => {
3
+ if (!(y && t.isBefore(y, "day") || h && t.isAfter(h, "day")))
4
+ if (B(null), !r.start || r.start && r.end) {
5
+ if (o({ start: t, end: null }), a === "left") {
6
+ const s = t.add(1, "month").startOf("month");
7
+ s.isSame(k) ? f(s.add(1, "month")) : f(s);
8
+ }
9
+ } else
10
+ t.isBefore(r.start, "day") ? o({ start: t, end: r.start }) : o({ ...r, end: t }), i && i({
11
+ start: t.isBefore(r.start, "day") ? t : r.start,
12
+ end: t.isBefore(r.start, "day") ? r.start : t
13
+ });
14
+ }, handleClosePicker: () => {
15
+ if (D && r.start && !r.end) {
16
+ const t = p(), a = t.isAfter(r.start) ? t : r.start, s = {
17
+ start: r.start,
18
+ end: a
19
+ };
20
+ o(s), i && i(s);
21
+ const n = s.start.startOf("month"), u = a.startOf("month");
22
+ n.isSame(u) ? (m(n), f(n.add(1, "month"))) : (m(n), f(u));
23
+ }
24
+ O(!1);
25
+ } });
26
+ export {
27
+ j as useChangeDate
28
+ };
@@ -0,0 +1,22 @@
1
+ const m = (e, n, t, c) => ({
2
+ navigateLeftMonth: (s) => {
3
+ const a = s === "prev" ? e.subtract(1, "month") : e.add(1, "month");
4
+ (a.isSame(n) || a.isAfter(n)) && c(a.add(1, "month")), t(a);
5
+ },
6
+ navigateRightMonth: (s) => {
7
+ const a = s === "prev" ? n.subtract(1, "month") : n.add(1, "month");
8
+ (a.isSame(e) || a.isBefore(e)) && t(a.subtract(1, "month")), c(a);
9
+ },
10
+ navigateYear: (s, a) => {
11
+ if (a === "left") {
12
+ const r = s === "prev" ? e.subtract(1, "year") : e.add(1, "year");
13
+ t(r), r.isAfter(n) && c(r.add(1, "month"));
14
+ } else {
15
+ const r = s === "prev" ? n.subtract(1, "year") : n.add(1, "year");
16
+ c(r), r.isBefore(e) && t(r.subtract(1, "month"));
17
+ }
18
+ }
19
+ });
20
+ export {
21
+ m as useDateNavigation
22
+ };
@@ -0,0 +1,24 @@
1
+ import { useState as d, useEffect as u } from "react";
2
+ import M from "../../../../_virtual/dayjs.min.js";
3
+ const a = (t) => {
4
+ const f = M(), [m, r] = d(f), [n, h] = d(f.add(1, "month")), [s, c] = d({
5
+ start: (t == null ? void 0 : t.start) || null,
6
+ end: (t == null ? void 0 : t.end) || null
7
+ });
8
+ return u(() => {
9
+ if (s.start && s.end) {
10
+ const e = s.start.startOf("month"), o = s.end.startOf("month");
11
+ e.isSame(o) ? (r(e), h(e.add(1, "month"))) : (e.isSame(m, "month") || r(e), !o.isSame(n, "month") && o.isAfter(e) && h(o));
12
+ }
13
+ }, [s]), {
14
+ leftMonth: m,
15
+ rightMonth: n,
16
+ setLeftMonth: r,
17
+ setRightMonth: h,
18
+ selectedRange: s,
19
+ setSelectedRange: c
20
+ };
21
+ };
22
+ export {
23
+ a as useDateRangeState
24
+ };
@@ -0,0 +1,77 @@
1
+ import b from "../../../../_virtual/dayjs.min.js";
2
+ import { useState as h } from "react";
3
+ const Q = (u, i, o, n, k, d) => {
4
+ const a = b(), [y, f] = h(null);
5
+ return {
6
+ activeQuickRange: y,
7
+ setQuickRange: (r) => {
8
+ let t, e = a;
9
+ switch (r) {
10
+ case "yesterday":
11
+ t = a.subtract(1, "day"), e = t;
12
+ break;
13
+ case "thisWeek":
14
+ t = a.startOf("week");
15
+ break;
16
+ case "lastWeek":
17
+ t = a.subtract(1, "week").startOf("week"), e = t.add(6, "day");
18
+ break;
19
+ case "thisMonth":
20
+ t = a.startOf("month");
21
+ break;
22
+ case "lastMonth":
23
+ t = a.subtract(1, "month").startOf("month"), e = t.endOf("month");
24
+ break;
25
+ case "thisYear":
26
+ t = a.startOf("year");
27
+ break;
28
+ case "lastYear":
29
+ t = a.subtract(1, "year").startOf("year"), e = t.endOf("year");
30
+ break;
31
+ default:
32
+ t = a;
33
+ }
34
+ if (f(r), u({ start: t, end: e }), d && d({ start: t, end: e }), t && e) {
35
+ const s = t.startOf("month"), c = e.startOf("month");
36
+ s.isSame(c) ? (i(s), o(s.add(1, "month"))) : (i(s), o(c));
37
+ }
38
+ },
39
+ isQuickRangeDisabled: (r) => {
40
+ let t, e = a;
41
+ switch (r) {
42
+ case "today":
43
+ t = a, e = a;
44
+ break;
45
+ case "yesterday":
46
+ t = a.subtract(1, "day"), e = t;
47
+ break;
48
+ case "thisWeek":
49
+ t = a.startOf("week");
50
+ break;
51
+ case "lastWeek":
52
+ t = a.subtract(1, "week").startOf("week"), e = t.add(6, "day");
53
+ break;
54
+ case "thisMonth":
55
+ t = a.startOf("month");
56
+ break;
57
+ case "lastMonth":
58
+ t = a.subtract(1, "month").startOf("month"), e = t.endOf("month");
59
+ break;
60
+ case "thisYear":
61
+ t = a.startOf("year");
62
+ break;
63
+ case "lastYear":
64
+ t = a.subtract(1, "year").startOf("year"), e = t.endOf("year");
65
+ break;
66
+ default:
67
+ return !1;
68
+ }
69
+ const s = !n || t.isAfter(n, "day") || t.isSame(n, "day"), c = !k || e.isBefore(k, "day") || e.isSame(k, "day");
70
+ return !s || !c;
71
+ },
72
+ setActiveQuickRange: f
73
+ };
74
+ };
75
+ export {
76
+ Q as useQuickRange
77
+ };
@@ -0,0 +1,4 @@
1
+ import { DateRangePicker as a } from "./DateRangePicker.js";
2
+ export {
3
+ a as DateRangePicker
4
+ };
package/dist/main.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { ComponentType } from 'react';
2
2
  import { Context } from 'react';
3
+ import { Dayjs } from 'dayjs';
3
4
  import { default as default_2 } from 'react';
4
5
  import { FC } from 'react';
5
6
  import { ForwardRefExoticComponent } from 'react';
@@ -132,6 +133,38 @@ export declare type Column<T extends object = Record<string, unknown>> = {
132
133
 
133
134
  export declare const CustomLink: default_2.FC<LinkProps>;
134
135
 
136
+ export declare const DatePicker: default_2.FC<DatePickerProps>;
137
+
138
+ declare interface DatePickerProps {
139
+ name?: string;
140
+ value?: Date | null;
141
+ onChange?: (date: Date | null) => void;
142
+ placeholder?: string;
143
+ className?: string;
144
+ inputClassName?: string;
145
+ calendarClassName?: string;
146
+ minDate?: Date;
147
+ maxDate?: Date;
148
+ }
149
+
150
+ export declare const DateRangePicker: default_2.FC<DateRangePickerProps>;
151
+
152
+ declare interface DateRangePickerProps {
153
+ disabledBefore?: Dayjs;
154
+ disabledAfter?: Dayjs;
155
+ onChange?: (range: {
156
+ start: Dayjs;
157
+ end: Dayjs;
158
+ }) => void;
159
+ initialRange?: {
160
+ start: Dayjs;
161
+ end: Dayjs;
162
+ };
163
+ className?: string;
164
+ placeholder: string;
165
+ autoCompleteWithToday?: boolean;
166
+ }
167
+
135
168
  export declare const DropdownInput: default_2.FC<DropdownInputProps>;
136
169
 
137
170
  declare type DropdownInputProps = {