@invoicebox/ui 0.1.0-alpha.120 → 0.1.0-alpha.122

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.
@@ -16,6 +16,6 @@ var Installation = exports.Installation = {
16
16
  render: function render() {
17
17
  return /*#__PURE__*/_react["default"].createElement(_Typography.Typography, {
18
18
  variant: "bodyL"
19
- }, /*#__PURE__*/_react["default"].createElement(_markdownToJsx["default"], null, "\n### \u0423\u0441\u0442\u0430\u043D\u043E\u0432\u043A\u0430\n\n\u0418\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u0435\u0442\u0441\u044F \u0431\u0438\u0431\u043B\u0438\u043E\u0442\u0435\u043A\u0430 [react-calendar](https://github.com/wojtekmaj/react-calendar).\n\u0414\u043B\u044F \u043A\u043E\u0440\u0440\u0435\u043A\u0442\u043D\u043E\u0439 \u0440\u0430\u0431\u043E\u0442\u044B \u043D\u0435\u043E\u0431\u0445\u043E\u0434\u0438\u043C\u043E \u043F\u043E\u0434\u043A\u043B\u044E\u0447\u0438\u0442\u044C \u0441\u0442\u0438\u043B\u0438.\n\n```ts\nimport 'react-calendar/dist/Calendar.css';\nimport '@invoicebox/ui/dist/components/common/Calendar/index.css';\n```\n"));
19
+ }, /*#__PURE__*/_react["default"].createElement(_markdownToJsx["default"], null, "\n### \u0423\u0441\u0442\u0430\u043D\u043E\u0432\u043A\u0430\n\n\u0418\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u0435\u0442\u0441\u044F \u0431\u0438\u0431\u043B\u0438\u043E\u0442\u0435\u043A\u0430 [react-calendar](https://github.com/wojtekmaj/react-calendar).\n\u0414\u043B\u044F \u043A\u043E\u0440\u0440\u0435\u043A\u0442\u043D\u043E\u0439 \u0440\u0430\u0431\u043E\u0442\u044B \u043D\u0435\u043E\u0431\u0445\u043E\u0434\u0438\u043C\u043E \u043F\u043E\u0434\u043A\u043B\u044E\u0447\u0438\u0442\u044C \u0441\u0442\u0438\u043B\u0438.\n\n```ts\nimport 'react-calendar/dist/Calendar.css';\n```\n"));
20
20
  }
21
21
  };
@@ -1,8 +1,16 @@
1
1
  import { FC } from 'react';
2
- export type TProps = {
3
- onChange: (value: Date) => void;
4
- value: null | Date;
2
+ type TGeneralProps = {
5
3
  minDate?: Date;
6
4
  maxDate?: Date;
7
5
  };
6
+ export type TProps = TGeneralProps & ({
7
+ onChange: (value: Date) => void;
8
+ value: null | Date;
9
+ selectRange?: false;
10
+ } | {
11
+ onChange: (value: [Date, Date]) => void;
12
+ value: null | [Date, Date];
13
+ selectRange: true;
14
+ });
8
15
  export declare const Calendar: FC<TProps>;
16
+ export {};
@@ -6,27 +6,25 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.Calendar = void 0;
8
8
  var _react = _interopRequireWildcard(require("react"));
9
- var _reactCalendar = _interopRequireDefault(require("react-calendar"));
10
9
  var _palette = require("../../../palette");
11
- var _useCss = require("../../../hooks/useCss");
12
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
10
+ var _styles = require("./styles");
13
11
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
14
12
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
15
- var CSS_ID = 'INVOICEBOX_UI_CALENDAR';
16
13
  var Calendar = exports.Calendar = function Calendar(_ref) {
17
14
  var onChange = _ref.onChange,
18
15
  value = _ref.value,
19
16
  minDate = _ref.minDate,
20
- maxDate = _ref.maxDate;
17
+ maxDate = _ref.maxDate,
18
+ selectRange = _ref.selectRange;
21
19
  var palette = (0, _palette.useComponentPalette)('calendar');
22
- (0, _useCss.useCss)({
23
- id: CSS_ID,
24
- css: ":root {\n --invoicebox-ui-calendar-arrow: ".concat(palette.arrow, ";\n --invoicebox-ui-calendar-weekday: ").concat(palette.weekday, ";\n --invoicebox-ui-calendar-tile: ").concat(palette.tile, ";\n --invoicebox-ui-calendar-tile-active: ").concat(palette.tileActive, ";\n --invoicebox-ui-calendar-tile-bg-active: ").concat(palette.tileBgActive, ";\n }")
25
- });
26
20
  var handleChange = (0, _react.useCallback)(function (newValue) {
27
- onChange(newValue);
28
- }, [onChange]);
29
- return /*#__PURE__*/_react["default"].createElement(_reactCalendar["default"], {
21
+ if (selectRange) {
22
+ onChange(newValue);
23
+ } else {
24
+ onChange(newValue);
25
+ }
26
+ }, [onChange, selectRange]);
27
+ return /*#__PURE__*/_react["default"].createElement(_styles.LibCalendar, {
30
28
  locale: "ru",
31
29
  minDate: minDate,
32
30
  maxDate: maxDate,
@@ -35,6 +33,15 @@ var Calendar = exports.Calendar = function Calendar(_ref) {
35
33
  next2Label: null,
36
34
  prev2Label: null,
37
35
  onChange: handleChange,
38
- value: value
36
+ value: value,
37
+ selectRange: selectRange
38
+ // styles
39
+ ,
40
+ $arrow: palette.arrow,
41
+ $weekDay: palette.weekday,
42
+ $tile: palette.tile,
43
+ $tileActive: palette.tileActive,
44
+ $tileBgActive: palette.tileBgActive,
45
+ $tileBgRangeBetween: palette.tileBgRangeBetween
39
46
  });
40
47
  };
@@ -1,7 +1,7 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react';
2
2
  import { Calendar } from '.';
3
3
  import 'react-calendar/dist/Calendar.css';
4
- import './index.css';
5
4
  declare const meta: Meta<typeof Calendar>;
6
5
  export default meta;
7
6
  export declare const Default: StoryObj<typeof Calendar>;
7
+ export declare const Range: StoryObj<typeof Calendar>;
@@ -4,12 +4,11 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports["default"] = exports.Default = void 0;
7
+ exports["default"] = exports.Range = exports.Default = void 0;
8
8
  var _react = _interopRequireWildcard(require("react"));
9
9
  var _addonActions = require("@storybook/addon-actions");
10
10
  var _ = require(".");
11
11
  require("react-calendar/dist/Calendar.css");
12
- require("./index.css");
13
12
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
14
13
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
15
14
  function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
@@ -42,14 +41,38 @@ var Component = function Component(_ref) {
42
41
  minDate: minDate ? new Date(minDate) : undefined
43
42
  });
44
43
  };
44
+ var RangeComponent = function RangeComponent(_ref2) {
45
+ var maxDate = _ref2.maxDate,
46
+ minDate = _ref2.minDate;
47
+ var _useState3 = (0, _react.useState)(null),
48
+ _useState4 = _slicedToArray(_useState3, 2),
49
+ value = _useState4[0],
50
+ setValue = _useState4[1];
51
+ var handleChange = (0, _react.useCallback)(function (date) {
52
+ setValue(date);
53
+ (0, _addonActions.action)('change')(date);
54
+ }, []);
55
+ return /*#__PURE__*/_react["default"].createElement(_.Calendar, {
56
+ value: value,
57
+ onChange: handleChange,
58
+ maxDate: maxDate ? new Date(maxDate) : undefined,
59
+ minDate: minDate ? new Date(minDate) : undefined,
60
+ selectRange: true
61
+ });
62
+ };
45
63
  var maxDate = new Date();
46
64
  maxDate.setMonth(maxDate.getMonth() + 1);
47
65
  var minDate = new Date();
48
66
  minDate.setMonth(minDate.getMonth() - 1);
67
+ var generalProps = {
68
+ maxDate: maxDate,
69
+ minDate: minDate
70
+ };
49
71
  var Default = exports.Default = {
50
72
  render: Component,
51
- args: {
52
- maxDate: maxDate,
53
- minDate: minDate
54
- }
73
+ args: generalProps
74
+ };
75
+ var Range = exports.Range = {
76
+ render: RangeComponent,
77
+ args: generalProps
55
78
  };
@@ -5,5 +5,6 @@ export type TCalendarPalette = {
5
5
  tile: string;
6
6
  tileActive: string;
7
7
  tileBgActive: string;
8
+ tileBgRangeBetween: string;
8
9
  };
9
10
  export declare const generateCalendarPalette: (abstractPalette: TAbstractPalette) => TCalendarPalette;
@@ -12,6 +12,7 @@ var generateCalendarPalette = exports.generateCalendarPalette = function generat
12
12
  weekday: (0, _hexToRgba["default"])(abstractPalette.primary, 0.4),
13
13
  tile: (0, _hexToRgba["default"])(abstractPalette.primary, 0.7),
14
14
  tileActive: abstractPalette.primary,
15
- tileBgActive: abstractPalette.secondary
15
+ tileBgActive: abstractPalette.secondary,
16
+ tileBgRangeBetween: (0, _hexToRgba["default"])(abstractPalette.primary, 0.05)
16
17
  };
17
18
  };
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ export declare const LibCalendar: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<Omit<import("react-calendar").CalendarProps & import("react").RefAttributes<unknown>, "ref"> & {
3
+ ref?: ((instance: unknown) => void) | import("react").RefObject<unknown> | null | undefined;
4
+ }, {
5
+ $arrow: string;
6
+ $weekDay: string;
7
+ $tile: string;
8
+ $tileActive: string;
9
+ $tileBgActive: string;
10
+ $tileBgRangeBetween: string;
11
+ selectRange?: boolean | undefined;
12
+ }>> & string & Omit<import("react").ForwardRefExoticComponent<import("react-calendar").CalendarProps & import("react").RefAttributes<unknown>>, keyof import("react").Component<any, {}, any>>;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.LibCalendar = void 0;
7
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
8
+ var _reactCalendar = _interopRequireDefault(require("react-calendar"));
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
10
+ var LibCalendar = exports.LibCalendar = (0, _styledComponents["default"])(_reactCalendar["default"]).withConfig({
11
+ displayName: "styles__LibCalendar",
12
+ componentId: "sc-1evd6f-0"
13
+ })(["border:none;width:240px;min-width:210px;background:transparent;@media (max-width:320px){width:225px;}.react-calendar__navigation{margin-bottom:0;}.react-calendar__navigation__arrow{font-size:24px;background-color:transparent !important;color:", ";}.react-calendar__navigation__arrow:disabled{opacity:0.4;cursor:default;}.react-calendar__navigation__arrow:hover:not([disabled]){opacity:0.6;}.react-calendar__navigation__label{font-size:14px;background-color:transparent !important;cursor:default;}.react-calendar__month-view__weekdays__weekday{color:", ";font-size:12px;font-weight:400;}.react-calendar__month-view__weekdays__weekday abbr{text-decoration:none;}.react-calendar__tile{font-size:12px;color:", ";background-color:transparent !important;padding:4px 6.6667px;border-radius:5px;margin-bottom:4px;}.react-calendar__tile:disabled{opacity:0.4;cursor:default;}.react-calendar__tile:hover:not([disabled]){opacity:0.6;}.react-calendar__tile--active{background-color:", " !important;color:", ";}.react-calendar__tile--active:hover{opacity:1 !important;}", ""], function (_ref) {
14
+ var $arrow = _ref.$arrow;
15
+ return $arrow;
16
+ }, function (_ref2) {
17
+ var $weekDay = _ref2.$weekDay;
18
+ return $weekDay;
19
+ }, function (_ref3) {
20
+ var $tile = _ref3.$tile;
21
+ return $tile;
22
+ }, function (_ref4) {
23
+ var $tileBgActive = _ref4.$tileBgActive;
24
+ return $tileBgActive;
25
+ }, function (_ref5) {
26
+ var $tileActive = _ref5.$tileActive;
27
+ return $tileActive;
28
+ }, function (_ref6) {
29
+ var selectRange = _ref6.selectRange,
30
+ $tileBgActive = _ref6.$tileBgActive,
31
+ $tileBgRangeBetween = _ref6.$tileBgRangeBetween;
32
+ return selectRange && "\n .react-calendar__tile--range {\n border-radius: 0;\n }\n\n .react-calendar__tile--rangeBothEnds {\n border-radius: 5px;\n }\n \n .react-calendar__tile--active {\n background-color: ".concat($tileBgRangeBetween, " !important;\n }\n\n .react-calendar__tile--rangeStart {\n border-top-left-radius: 5px;\n border-bottom-left-radius: 5px;\n background-color: ").concat($tileBgActive, " !important;\n }\n\n .react-calendar__tile--rangeEnd {\n border-top-right-radius: 5px;\n border-bottom-right-radius: 5px;\n background-color: ").concat($tileBgActive, " !important;\n }\n ");
33
+ });
@@ -1,7 +1,6 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react';
2
2
  import { DateInput } from '.';
3
3
  import 'react-calendar/dist/Calendar.css';
4
- import '../../common/Calendar/index.css';
5
4
  declare const meta: Meta<typeof DateInput>;
6
5
  export default meta;
7
6
  export declare const Default: StoryObj<typeof DateInput>;
@@ -9,7 +9,6 @@ var _react = _interopRequireWildcard(require("react"));
9
9
  var _addonActions = require("@storybook/addon-actions");
10
10
  var _ = require(".");
11
11
  require("react-calendar/dist/Calendar.css");
12
- require("../../common/Calendar/index.css");
13
12
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
14
13
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
15
14
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@invoicebox/ui",
3
- "version": "0.1.0-alpha.120",
3
+ "version": "0.1.0-alpha.122",
4
4
  "description": "Invoicebox UI",
5
5
  "license": "Apache License 2.0",
6
6
  "scripts": {
@@ -1,81 +0,0 @@
1
- .react-calendar {
2
- border: none;
3
- width: 240px;
4
- min-width: 210px;
5
- background: transparent;
6
-
7
- @media (max-width: 320px) {
8
- width: 225px;
9
- }
10
- }
11
-
12
- /* navigation block */
13
-
14
- .react-calendar__navigation {
15
- margin-bottom: 0;
16
- }
17
-
18
- /* navigation arrow */
19
-
20
- .react-calendar__navigation__arrow {
21
- font-size: 24px;
22
- background-color: transparent !important;
23
- color: var(--invoicebox-ui-calendar-arrow);
24
- }
25
-
26
- .react-calendar__navigation__arrow:disabled {
27
- opacity: 0.4;
28
- cursor: default;
29
- }
30
-
31
- .react-calendar__navigation__arrow:hover:not([disabled]) {
32
- opacity: 0.6;
33
- }
34
-
35
- /* navigation label */
36
-
37
- .react-calendar__navigation__label {
38
- font-size: 14px;
39
- background-color: transparent !important;
40
- cursor: default;
41
- }
42
-
43
- /* weekdays */
44
-
45
- .react-calendar__month-view__weekdays__weekday {
46
- color: var(--invoicebox-ui-calendar-weekday);
47
- font-size: 12px;
48
- font-weight: 400;
49
- }
50
-
51
- .react-calendar__month-view__weekdays__weekday abbr {
52
- text-decoration: none;
53
- }
54
-
55
- /* day */
56
-
57
- .react-calendar__tile {
58
- font-size: 12px;
59
- color: var(--invoicebox-ui-calendar-tile);
60
- background-color: transparent !important;
61
- padding: 4px 6.6667px;
62
- border-radius: 6px;
63
- }
64
-
65
- .react-calendar__tile:disabled {
66
- opacity: 0.4;
67
- cursor: default;
68
- }
69
-
70
- .react-calendar__tile:hover:not([disabled]) {
71
- opacity: 0.6;
72
- }
73
-
74
- .react-calendar__tile--active {
75
- background-color: var(--invoicebox-ui-calendar-tile-bg-active) !important;
76
- color: var(--invoicebox-ui-calendar-tile-active);
77
- }
78
-
79
- .react-calendar__tile--active:hover {
80
- opacity: 1 !important;
81
- }
@@ -1 +0,0 @@
1
- "use strict";