@dhis2-ui/calendar 9.11.3 → 9.11.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -22,10 +22,10 @@ const Calendar = _ref => {
22
22
  dir,
23
23
  locale,
24
24
  numberingSystem,
25
- weekDayFormat,
25
+ weekDayFormat = 'narrow',
26
26
  timeZone,
27
- width,
28
- cellSize
27
+ width = '240px',
28
+ cellSize = '32px'
29
29
  } = _ref;
30
30
  const wrapperBorderColor = _uiConstants.colors.grey300;
31
31
  const backgroundColor = 'none';
@@ -74,11 +74,6 @@ const Calendar = _ref => {
74
74
  }, [`.calendar-wrapper.__jsx-style-dynamic-selector{font-family:Roboto,sans-serif;font-weight:400;font-size:14px;background-color:${backgroundColor};display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;border:1px solid ${wrapperBorderColor};border-radius:3px;min-width:${width};width:-webkit-max-content;width:-moz-max-content;width:max-content;box-shadow:0px 4px 6px -2px #2129340d;box-shadow:0px 10px 15px -3px #2129341a;}`]));
75
75
  };
76
76
  exports.Calendar = Calendar;
77
- Calendar.defaultProps = {
78
- cellSize: '32px',
79
- width: '240px',
80
- weekDayFormat: 'narrow'
81
- };
82
77
  const CalendarProps = exports.CalendarProps = {
83
78
  /** the calendar to use such gregory, ethiopic, nepali - full supported list here: https://github.com/dhis2/multi-calendar-dates/blob/main/src/constants/calendars.ts */
84
79
  calendar: _propTypes.default.any.isRequired,
@@ -37,6 +37,7 @@ const CalendarInput = function () {
37
37
  width,
38
38
  cellSize,
39
39
  clearable,
40
+ dataTest = 'dhis2-uiwidgets-calendar-inputfield',
40
41
  ...rest
41
42
  } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
42
43
  const ref = (0, _react.useRef)();
@@ -68,6 +69,7 @@ const CalendarInput = function () {
68
69
  }, /*#__PURE__*/_react.default.createElement(_input.InputField, _extends({
69
70
  label: _index.default.t('Pick a date')
70
71
  }, rest, {
72
+ dataTest: dataTest,
71
73
  type: "text",
72
74
  onFocus: onFocus,
73
75
  value: date
@@ -100,9 +102,6 @@ const CalendarInput = function () {
100
102
  }, [".calendar-input-wrapper.jsx-862452676{position:relative;}", ".calendar-clear-button.jsx-862452676{position:absolute;inset-inline-end:6px;-webkit-inset-block-start:27px;-ms-intb-rlock-start:27px;inset-block-start:27px;}", ".calendar-clear-button.with-icon.jsx-862452676{inset-inline-end:36px;}", ".calendar-clear-button.with-dense-wrapper.jsx-862452676{-webkit-inset-block-start:23px;-ms-intb-rlock-start:23px;inset-block-start:23px;}"]));
101
103
  };
102
104
  exports.CalendarInput = CalendarInput;
103
- CalendarInput.defaultProps = {
104
- dataTest: 'dhis2-uiwidgets-calendar-inputfield'
105
- };
106
105
  CalendarInput.propTypes = {
107
106
  ..._calendar.CalendarProps,
108
107
  ..._input.InputFieldProps
@@ -19,13 +19,13 @@ const {
19
19
  const CalendarStoryWrapper = props => {
20
20
  var _selectedDate$calenda;
21
21
  const {
22
- calendar,
22
+ calendar = 'gregory',
23
23
  locale,
24
24
  timeZone,
25
25
  dir,
26
- component: Component,
26
+ component: Component = _calendar.Calendar,
27
27
  date,
28
- weekDayFormat
28
+ weekDayFormat = 'narrow'
29
29
  } = props;
30
30
  const [selectedCalendar, setSelectedCalendar] = (0, _react.useState)(calendar);
31
31
  const [selectedNumberingSystem, setSelectedNumberingSystem] = (0, _react.useState)();
@@ -165,11 +165,6 @@ const CalendarStoryWrapper = props => {
165
165
  }))), /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("label", null, "callback:"), JSON.stringify(selectedDate, null, 2))))));
166
166
  };
167
167
  exports.CalendarStoryWrapper = CalendarStoryWrapper;
168
- CalendarStoryWrapper.defaultProps = {
169
- calendar: 'gregorian',
170
- component: _calendar.Calendar,
171
- weekDayFormat: 'narrow'
172
- };
173
168
  CalendarStoryWrapper.propTypes = {
174
169
  calendar: _propTypes.default.string.isRequired,
175
170
  component: _propTypes.default.elementType.isRequired,
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = exports.WithAnyCalendar = exports.Nepali = exports.Ethiopic = void 0;
6
+ exports.default = exports.WithAnyCalendar = exports.Nepali = exports.Ethiopic = exports.Basic = void 0;
7
7
  var _react = _interopRequireDefault(require("react"));
8
8
  var _calendar = require("../calendar/calendar.js");
9
9
  var _calendarStoryWrapper = require("./calendar-story-wrapper.js");
@@ -29,8 +29,35 @@ var _default = exports.default = {
29
29
  component: description
30
30
  }
31
31
  }
32
+ },
33
+ argTypes: {
34
+ calendar: {
35
+ control: 'select',
36
+ options: ['gregory', 'islamic', 'nepali', 'ethiopic', 'persian', 'indian']
37
+ },
38
+ weekDayFormat: {
39
+ control: 'select',
40
+ options: ['long', 'short', 'narrow']
41
+ },
42
+ locale: {
43
+ control: 'text'
44
+ },
45
+ numberingSystem: {
46
+ control: 'select',
47
+ options: ['latn', 'arab', 'ethi']
48
+ }
32
49
  }
33
50
  };
51
+ const Basic = args => {
52
+ return /*#__PURE__*/_react.default.createElement(_calendar.Calendar, args);
53
+ };
54
+ exports.Basic = Basic;
55
+ Basic.args = {
56
+ onDateSelect: date => console.log(date),
57
+ calendar: 'gregory',
58
+ weekDayFormat: 'narrow',
59
+ locale: 'en'
60
+ };
34
61
  const Ethiopic = args => {
35
62
  return /*#__PURE__*/_react.default.createElement(_calendarStoryWrapper.CalendarStoryWrapper, _extends({
36
63
  calendar: "ethiopic",
@@ -13,10 +13,10 @@ export const Calendar = _ref => {
13
13
  dir,
14
14
  locale,
15
15
  numberingSystem,
16
- weekDayFormat,
16
+ weekDayFormat = 'narrow',
17
17
  timeZone,
18
- width,
19
- cellSize
18
+ width = '240px',
19
+ cellSize = '32px'
20
20
  } = _ref;
21
21
  const wrapperBorderColor = colors.grey300;
22
22
  const backgroundColor = 'none';
@@ -64,11 +64,6 @@ export const Calendar = _ref => {
64
64
  dynamic: [backgroundColor, wrapperBorderColor, width]
65
65
  }, [`.calendar-wrapper.__jsx-style-dynamic-selector{font-family:Roboto,sans-serif;font-weight:400;font-size:14px;background-color:${backgroundColor};display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;border:1px solid ${wrapperBorderColor};border-radius:3px;min-width:${width};width:-webkit-max-content;width:-moz-max-content;width:max-content;box-shadow:0px 4px 6px -2px #2129340d;box-shadow:0px 10px 15px -3px #2129341a;}`]));
66
66
  };
67
- Calendar.defaultProps = {
68
- cellSize: '32px',
69
- width: '240px',
70
- weekDayFormat: 'narrow'
71
- };
72
67
  export const CalendarProps = {
73
68
  /** the calendar to use such gregory, ethiopic, nepali - full supported list here: https://github.com/dhis2/multi-calendar-dates/blob/main/src/constants/calendars.ts */
74
69
  calendar: PropTypes.any.isRequired,
@@ -28,6 +28,7 @@ export const CalendarInput = function () {
28
28
  width,
29
29
  cellSize,
30
30
  clearable,
31
+ dataTest = 'dhis2-uiwidgets-calendar-inputfield',
31
32
  ...rest
32
33
  } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
33
34
  const ref = useRef();
@@ -59,6 +60,7 @@ export const CalendarInput = function () {
59
60
  }, /*#__PURE__*/React.createElement(InputField, _extends({
60
61
  label: i18n.t('Pick a date')
61
62
  }, rest, {
63
+ dataTest: dataTest,
62
64
  type: "text",
63
65
  onFocus: onFocus,
64
66
  value: date
@@ -90,9 +92,6 @@ export const CalendarInput = function () {
90
92
  id: "862452676"
91
93
  }, [".calendar-input-wrapper.jsx-862452676{position:relative;}", ".calendar-clear-button.jsx-862452676{position:absolute;inset-inline-end:6px;-webkit-inset-block-start:27px;-ms-intb-rlock-start:27px;inset-block-start:27px;}", ".calendar-clear-button.with-icon.jsx-862452676{inset-inline-end:36px;}", ".calendar-clear-button.with-dense-wrapper.jsx-862452676{-webkit-inset-block-start:23px;-ms-intb-rlock-start:23px;inset-block-start:23px;}"]));
92
94
  };
93
- CalendarInput.defaultProps = {
94
- dataTest: 'dhis2-uiwidgets-calendar-inputfield'
95
- };
96
95
  CalendarInput.propTypes = {
97
96
  ...CalendarProps,
98
97
  ...InputFieldProps
@@ -10,13 +10,13 @@ const {
10
10
  export const CalendarStoryWrapper = props => {
11
11
  var _selectedDate$calenda;
12
12
  const {
13
- calendar,
13
+ calendar = 'gregory',
14
14
  locale,
15
15
  timeZone,
16
16
  dir,
17
- component: Component,
17
+ component: Component = Calendar,
18
18
  date,
19
- weekDayFormat
19
+ weekDayFormat = 'narrow'
20
20
  } = props;
21
21
  const [selectedCalendar, setSelectedCalendar] = useState(calendar);
22
22
  const [selectedNumberingSystem, setSelectedNumberingSystem] = useState();
@@ -155,11 +155,6 @@ export const CalendarStoryWrapper = props => {
155
155
  dateStyle: 'long'
156
156
  }))), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("label", null, "callback:"), JSON.stringify(selectedDate, null, 2))))));
157
157
  };
158
- CalendarStoryWrapper.defaultProps = {
159
- calendar: 'gregorian',
160
- component: Calendar,
161
- weekDayFormat: 'narrow'
162
- };
163
158
  CalendarStoryWrapper.propTypes = {
164
159
  calendar: PropTypes.string.isRequired,
165
160
  component: PropTypes.elementType.isRequired,
@@ -22,8 +22,34 @@ export default {
22
22
  component: description
23
23
  }
24
24
  }
25
+ },
26
+ argTypes: {
27
+ calendar: {
28
+ control: 'select',
29
+ options: ['gregory', 'islamic', 'nepali', 'ethiopic', 'persian', 'indian']
30
+ },
31
+ weekDayFormat: {
32
+ control: 'select',
33
+ options: ['long', 'short', 'narrow']
34
+ },
35
+ locale: {
36
+ control: 'text'
37
+ },
38
+ numberingSystem: {
39
+ control: 'select',
40
+ options: ['latn', 'arab', 'ethi']
41
+ }
25
42
  }
26
43
  };
44
+ export const Basic = args => {
45
+ return /*#__PURE__*/React.createElement(Calendar, args);
46
+ };
47
+ Basic.args = {
48
+ onDateSelect: date => console.log(date),
49
+ calendar: 'gregory',
50
+ weekDayFormat: 'narrow',
51
+ locale: 'en'
52
+ };
27
53
  export const Ethiopic = args => {
28
54
  return /*#__PURE__*/React.createElement(CalendarStoryWrapper, _extends({
29
55
  calendar: "ethiopic",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhis2-ui/calendar",
3
- "version": "9.11.3",
3
+ "version": "9.11.5",
4
4
  "description": "UI Calendar",
5
5
  "repository": {
6
6
  "type": "git",
@@ -33,15 +33,15 @@
33
33
  "styled-jsx": "^4"
34
34
  },
35
35
  "dependencies": {
36
- "@dhis2-ui/button": "9.11.3",
37
- "@dhis2-ui/card": "9.11.3",
38
- "@dhis2-ui/input": "9.11.3",
39
- "@dhis2-ui/layer": "9.11.3",
40
- "@dhis2-ui/popper": "9.11.3",
36
+ "@dhis2-ui/button": "9.11.5",
37
+ "@dhis2-ui/card": "9.11.5",
38
+ "@dhis2-ui/input": "9.11.5",
39
+ "@dhis2-ui/layer": "9.11.5",
40
+ "@dhis2-ui/popper": "9.11.5",
41
41
  "@dhis2/multi-calendar-dates": "^1.2.3",
42
42
  "@dhis2/prop-types": "^3.1.2",
43
- "@dhis2/ui-constants": "9.11.3",
44
- "@dhis2/ui-icons": "9.11.3",
43
+ "@dhis2/ui-constants": "9.11.5",
44
+ "@dhis2/ui-icons": "9.11.5",
45
45
  "classnames": "^2.3.1",
46
46
  "prop-types": "^15.7.2"
47
47
  },