@dhis2-ui/modal 9.11.3 → 9.11.5

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.
@@ -27,12 +27,12 @@ const Modal = _ref => {
27
27
  let {
28
28
  children,
29
29
  className,
30
- dataTest,
30
+ dataTest = 'dhis2-uicore-modal',
31
31
  hide,
32
32
  fluid,
33
33
  large,
34
34
  onClose,
35
- position,
35
+ position = 'top',
36
36
  small
37
37
  } = _ref;
38
38
  const layerStyles = resolveLayerStyles(hide);
@@ -77,10 +77,6 @@ const Modal = _ref => {
77
77
  }, [`aside.__jsx-style-dynamic-selector{height:auto;width:600px;max-width:calc(100vw - ${2 * _uiConstants.spacersNum.dp64}px);max-height:calc(100vh - ${2 * _uiConstants.spacersNum.dp64}px);}`, "aside.small.__jsx-style-dynamic-selector{width:400px;}", "aside.large.__jsx-style-dynamic-selector{width:800px;}", "aside.fluid.__jsx-style-dynamic-selector{width:auto;}", `div.__jsx-style-dynamic-selector{padding:24px;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-flow:column;-ms-flex-flow:column;flex-flow:column;max-width:calc(100vw - ${2 * _uiConstants.spacersNum.dp64}px);max-height:calc(100vh - ${2 * _uiConstants.spacersNum.dp64}px);}`]));
78
78
  };
79
79
  exports.Modal = Modal;
80
- Modal.defaultProps = {
81
- dataTest: 'dhis2-uicore-modal',
82
- position: 'top'
83
- };
84
80
  Modal.propTypes = {
85
81
  children: _propTypes.default.node,
86
82
  className: _propTypes.default.string,
@@ -3,12 +3,16 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = exports.TopScrollable = exports.SmallTitleContentAction = exports.SmallLongTitle = exports.SmallDestructivePrimary = exports.SmallContentPrimary = exports.SmallClickableScreenCover = exports.RTL = exports.ModalThatHidesWithStatefulComponens = exports.MiddleScrollable = exports.MediumTitleContentAction = exports.LargeWithSelectComponent = exports.LargeTitleContentPrimary = exports.LargeModalWithMoreNestedModals = exports.FluidTop = exports.FluidTitleContentPrimary = exports.FluidMiddle = exports.FluidBottom = exports.DefaultContent = exports.BottomScrollable = exports.AlignmentMiddle = exports.AlignmentBottom = void 0;
6
+ exports.default = exports.TopScrollable = exports.SmallTitleContentAction = exports.SmallLongTitle = exports.SmallDestructivePrimary = exports.SmallContentPrimary = exports.SmallClickableScreenCover = exports.RTL = exports.ModalWithLoadingState = exports.ModalWithErrorState = exports.ModalThatHidesWithStatefulComponens = exports.MiddleScrollable = exports.MediumTitleContentAction = exports.LargeWithSelectComponent = exports.LargeTitleContentPrimary = exports.LargeModalWithMoreNestedModals = exports.FluidTop = exports.FluidTitleContentPrimary = exports.FluidMiddle = exports.FluidBottom = exports.DefaultContent = exports.BottomScrollable = exports.AlignmentMiddle = exports.AlignmentBottom = void 0;
7
7
  var _style = _interopRequireDefault(require("styled-jsx/style"));
8
8
  var _uiConstants = require("@dhis2/ui-constants");
9
9
  var _box = require("@dhis2-ui/box");
10
10
  var _button = require("@dhis2-ui/button");
11
+ var _center = require("@dhis2-ui/center");
12
+ var _input = require("@dhis2-ui/input");
13
+ var _loader = require("@dhis2-ui/loader");
11
14
  var _menu = require("@dhis2-ui/menu");
15
+ var _noticeBox = require("@dhis2-ui/notice-box");
12
16
  var _select = require("@dhis2-ui/select");
13
17
  var _tooltip = require("@dhis2-ui/tooltip");
14
18
  var _react = _interopRequireWildcard(require("react"));
@@ -342,6 +346,42 @@ LargeWithSelectComponent.args = {
342
346
  large: true
343
347
  };
344
348
  LargeWithSelectComponent.storyName = 'Large: with Select component';
349
+ const ModalWithErrorState = args => /*#__PURE__*/_react.default.createElement(_modal.Modal, args, /*#__PURE__*/_react.default.createElement(_index.ModalTitle, null, "Update profile"), /*#__PURE__*/_react.default.createElement(_index.ModalContent, null, /*#__PURE__*/_react.default.createElement(_input.InputField, {
350
+ label: "First name",
351
+ required: true,
352
+ error: true,
353
+ validationText: "First name can't be empty.",
354
+ inputWidth: "320px"
355
+ }), /*#__PURE__*/_react.default.createElement(_input.InputField, {
356
+ label: "Last name",
357
+ value: "Olefeme",
358
+ required: true,
359
+ inputWidth: "320px"
360
+ }), /*#__PURE__*/_react.default.createElement(_box.Box, {
361
+ marginTop: "16px"
362
+ }, /*#__PURE__*/_react.default.createElement(_noticeBox.NoticeBox, {
363
+ error: true
364
+ }, "There is a problem with this form."))), /*#__PURE__*/_react.default.createElement(_index.ModalActions, null, /*#__PURE__*/_react.default.createElement(_button.ButtonStrip, {
365
+ end: true
366
+ }, /*#__PURE__*/_react.default.createElement(_button.Button, {
367
+ secondary: true
368
+ }, "Cancel"), /*#__PURE__*/_react.default.createElement(_button.Button, {
369
+ disabled: true,
370
+ primary: true
371
+ }, "Save changes"))));
372
+ exports.ModalWithErrorState = ModalWithErrorState;
373
+ ModalWithErrorState.storyName = 'With error state';
374
+ const ModalWithLoadingState = args => /*#__PURE__*/_react.default.createElement(_modal.Modal, args, /*#__PURE__*/_react.default.createElement(_index.ModalTitle, null, "Modal title"), /*#__PURE__*/_react.default.createElement(_index.ModalContent, null, /*#__PURE__*/_react.default.createElement(_box.Box, {
375
+ minHeight: "240px"
376
+ }, /*#__PURE__*/_react.default.createElement(_center.Center, null, /*#__PURE__*/_react.default.createElement(_loader.CircularLoader, null)))), /*#__PURE__*/_react.default.createElement(_index.ModalActions, null, /*#__PURE__*/_react.default.createElement(_button.ButtonStrip, {
377
+ end: true
378
+ }, /*#__PURE__*/_react.default.createElement(_button.Button, {
379
+ secondary: true
380
+ }, "Cancel"), /*#__PURE__*/_react.default.createElement(_button.Button, {
381
+ primary: true
382
+ }, "Save changes"))));
383
+ exports.ModalWithLoadingState = ModalWithLoadingState;
384
+ ModalWithLoadingState.storyName = 'With loading state';
345
385
  const LargeModalWithMoreNestedModals = args => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_modal.Modal, args, /*#__PURE__*/_react.default.createElement(_index.ModalTitle, null, "Select opens on top of the Modal - Level 1"), /*#__PURE__*/_react.default.createElement(_index.ModalContent, null, /*#__PURE__*/_react.default.createElement(_select.SingleSelect, null, /*#__PURE__*/_react.default.createElement(_select.SingleSelectOption, {
346
386
  key: "1",
347
387
  value: "1",
@@ -12,7 +12,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
12
12
  const ModalActions = _ref => {
13
13
  let {
14
14
  children,
15
- dataTest
15
+ dataTest = 'dhis2-uicore-modalactions'
16
16
  } = _ref;
17
17
  return /*#__PURE__*/_react.default.createElement("div", {
18
18
  "data-test": dataTest,
@@ -23,9 +23,6 @@ const ModalActions = _ref => {
23
23
  }, [`div.__jsx-style-dynamic-selector{-webkit-order:3;-ms-flex-order:3;order:3;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:end;-webkit-justify-content:flex-end;-ms-flex-pack:end;justify-content:flex-end;-webkit-align-self:flex-end;-ms-flex-item-align:end;align-self:flex-end;margin:${_uiConstants.spacers.dp16} 0 0;}`]));
24
24
  };
25
25
  exports.ModalActions = ModalActions;
26
- ModalActions.defaultProps = {
27
- dataTest: 'dhis2-uicore-modalactions'
28
- };
29
26
  ModalActions.propTypes = {
30
27
  children: _propTypes.default.node,
31
28
  dataTest: _propTypes.default.string
@@ -12,7 +12,7 @@ const ModalContent = _ref => {
12
12
  let {
13
13
  children,
14
14
  className,
15
- dataTest
15
+ dataTest = 'dhis2-uicore-modalcontent'
16
16
  } = _ref;
17
17
  return /*#__PURE__*/_react.default.createElement("div", {
18
18
  "data-test": dataTest,
@@ -22,9 +22,6 @@ const ModalContent = _ref => {
22
22
  }, ["div.jsx-3719215021{-webkit-order:2;-ms-flex-order:2;order:2;-webkit-box-flex:2;-webkit-flex-grow:2;-ms-flex-positive:2;flex-grow:2;overflow-y:auto;}"]));
23
23
  };
24
24
  exports.ModalContent = ModalContent;
25
- ModalContent.defaultProps = {
26
- dataTest: 'dhis2-uicore-modalcontent'
27
- };
28
25
  ModalContent.propTypes = {
29
26
  children: _propTypes.default.node,
30
27
  className: _propTypes.default.string,
@@ -13,7 +13,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
13
13
  const ModalTitle = _ref => {
14
14
  let {
15
15
  children,
16
- dataTest
16
+ dataTest = 'dhis2-uicore-modaltitle'
17
17
  } = _ref;
18
18
  return /*#__PURE__*/_react.default.createElement("h1", {
19
19
  "data-test": dataTest,
@@ -24,9 +24,6 @@ const ModalTitle = _ref => {
24
24
  }, [`h1.__jsx-style-dynamic-selector{-webkit-order:1;-ms-flex-order:1;order:1;-webkit-align-self:flex-start;-ms-flex-item-align:start;align-self:flex-start;color:${_uiConstants.colors.grey900};font-size:20px;font-weight:500;line-height:24px;margin:0 0 ${_uiConstants.spacers.dp12};}`]));
25
25
  };
26
26
  exports.ModalTitle = ModalTitle;
27
- ModalTitle.defaultProps = {
28
- dataTest: 'dhis2-uicore-modaltitle'
29
- };
30
27
  ModalTitle.propTypes = {
31
28
  children: _propTypes.default.node,
32
29
  dataTest: _propTypes.default.string
@@ -18,12 +18,12 @@ export const Modal = _ref => {
18
18
  let {
19
19
  children,
20
20
  className,
21
- dataTest,
21
+ dataTest = 'dhis2-uicore-modal',
22
22
  hide,
23
23
  fluid,
24
24
  large,
25
25
  onClose,
26
- position,
26
+ position = 'top',
27
27
  small
28
28
  } = _ref;
29
29
  const layerStyles = resolveLayerStyles(hide);
@@ -67,10 +67,6 @@ export const Modal = _ref => {
67
67
  dynamic: [2 * spacersNum.dp64, 2 * spacersNum.dp64, 2 * spacersNum.dp64, 2 * spacersNum.dp64]
68
68
  }, [`aside.__jsx-style-dynamic-selector{height:auto;width:600px;max-width:calc(100vw - ${2 * spacersNum.dp64}px);max-height:calc(100vh - ${2 * spacersNum.dp64}px);}`, "aside.small.__jsx-style-dynamic-selector{width:400px;}", "aside.large.__jsx-style-dynamic-selector{width:800px;}", "aside.fluid.__jsx-style-dynamic-selector{width:auto;}", `div.__jsx-style-dynamic-selector{padding:24px;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-flow:column;-ms-flex-flow:column;flex-flow:column;max-width:calc(100vw - ${2 * spacersNum.dp64}px);max-height:calc(100vh - ${2 * spacersNum.dp64}px);}`]));
69
69
  };
70
- Modal.defaultProps = {
71
- dataTest: 'dhis2-uicore-modal',
72
- position: 'top'
73
- };
74
70
  Modal.propTypes = {
75
71
  children: PropTypes.node,
76
72
  className: PropTypes.string,
@@ -2,7 +2,11 @@ import _JSXStyle from "styled-jsx/style";
2
2
  import { sharedPropTypes } from '@dhis2/ui-constants';
3
3
  import { Box } from '@dhis2-ui/box';
4
4
  import { Button, ButtonStrip } from '@dhis2-ui/button';
5
+ import { Center as CenteredContent } from '@dhis2-ui/center';
6
+ import { InputField } from '@dhis2-ui/input';
7
+ import { CircularLoader } from '@dhis2-ui/loader';
5
8
  import { FlyoutMenu, MenuDivider, MenuItem, MenuSectionHeader } from '@dhis2-ui/menu';
9
+ import { NoticeBox } from '@dhis2-ui/notice-box';
6
10
  import { SingleSelect, SingleSelectOption } from '@dhis2-ui/select';
7
11
  import { Tooltip } from '@dhis2-ui/tooltip';
8
12
  import React, { useEffect, useState } from 'react';
@@ -318,6 +322,40 @@ LargeWithSelectComponent.args = {
318
322
  large: true
319
323
  };
320
324
  LargeWithSelectComponent.storyName = 'Large: with Select component';
325
+ export const ModalWithErrorState = args => /*#__PURE__*/React.createElement(Modal, args, /*#__PURE__*/React.createElement(ModalTitle, null, "Update profile"), /*#__PURE__*/React.createElement(ModalContent, null, /*#__PURE__*/React.createElement(InputField, {
326
+ label: "First name",
327
+ required: true,
328
+ error: true,
329
+ validationText: "First name can't be empty.",
330
+ inputWidth: "320px"
331
+ }), /*#__PURE__*/React.createElement(InputField, {
332
+ label: "Last name",
333
+ value: "Olefeme",
334
+ required: true,
335
+ inputWidth: "320px"
336
+ }), /*#__PURE__*/React.createElement(Box, {
337
+ marginTop: "16px"
338
+ }, /*#__PURE__*/React.createElement(NoticeBox, {
339
+ error: true
340
+ }, "There is a problem with this form."))), /*#__PURE__*/React.createElement(ModalActions, null, /*#__PURE__*/React.createElement(ButtonStrip, {
341
+ end: true
342
+ }, /*#__PURE__*/React.createElement(Button, {
343
+ secondary: true
344
+ }, "Cancel"), /*#__PURE__*/React.createElement(Button, {
345
+ disabled: true,
346
+ primary: true
347
+ }, "Save changes"))));
348
+ ModalWithErrorState.storyName = 'With error state';
349
+ export const ModalWithLoadingState = args => /*#__PURE__*/React.createElement(Modal, args, /*#__PURE__*/React.createElement(ModalTitle, null, "Modal title"), /*#__PURE__*/React.createElement(ModalContent, null, /*#__PURE__*/React.createElement(Box, {
350
+ minHeight: "240px"
351
+ }, /*#__PURE__*/React.createElement(CenteredContent, null, /*#__PURE__*/React.createElement(CircularLoader, null)))), /*#__PURE__*/React.createElement(ModalActions, null, /*#__PURE__*/React.createElement(ButtonStrip, {
352
+ end: true
353
+ }, /*#__PURE__*/React.createElement(Button, {
354
+ secondary: true
355
+ }, "Cancel"), /*#__PURE__*/React.createElement(Button, {
356
+ primary: true
357
+ }, "Save changes"))));
358
+ ModalWithLoadingState.storyName = 'With loading state';
321
359
  export const LargeModalWithMoreNestedModals = args => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Modal, args, /*#__PURE__*/React.createElement(ModalTitle, null, "Select opens on top of the Modal - Level 1"), /*#__PURE__*/React.createElement(ModalContent, null, /*#__PURE__*/React.createElement(SingleSelect, null, /*#__PURE__*/React.createElement(SingleSelectOption, {
322
360
  key: "1",
323
361
  value: "1",
@@ -5,7 +5,7 @@ import React from 'react';
5
5
  export const ModalActions = _ref => {
6
6
  let {
7
7
  children,
8
- dataTest
8
+ dataTest = 'dhis2-uicore-modalactions'
9
9
  } = _ref;
10
10
  return /*#__PURE__*/React.createElement("div", {
11
11
  "data-test": dataTest,
@@ -15,9 +15,6 @@ export const ModalActions = _ref => {
15
15
  dynamic: [spacers.dp16]
16
16
  }, [`div.__jsx-style-dynamic-selector{-webkit-order:3;-ms-flex-order:3;order:3;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:end;-webkit-justify-content:flex-end;-ms-flex-pack:end;justify-content:flex-end;-webkit-align-self:flex-end;-ms-flex-item-align:end;align-self:flex-end;margin:${spacers.dp16} 0 0;}`]));
17
17
  };
18
- ModalActions.defaultProps = {
19
- dataTest: 'dhis2-uicore-modalactions'
20
- };
21
18
  ModalActions.propTypes = {
22
19
  children: PropTypes.node,
23
20
  dataTest: PropTypes.string
@@ -5,7 +5,7 @@ export const ModalContent = _ref => {
5
5
  let {
6
6
  children,
7
7
  className,
8
- dataTest
8
+ dataTest = 'dhis2-uicore-modalcontent'
9
9
  } = _ref;
10
10
  return /*#__PURE__*/React.createElement("div", {
11
11
  "data-test": dataTest,
@@ -14,9 +14,6 @@ export const ModalContent = _ref => {
14
14
  id: "3719215021"
15
15
  }, ["div.jsx-3719215021{-webkit-order:2;-ms-flex-order:2;order:2;-webkit-box-flex:2;-webkit-flex-grow:2;-ms-flex-positive:2;flex-grow:2;overflow-y:auto;}"]));
16
16
  };
17
- ModalContent.defaultProps = {
18
- dataTest: 'dhis2-uicore-modalcontent'
19
- };
20
17
  ModalContent.propTypes = {
21
18
  children: PropTypes.node,
22
19
  className: PropTypes.string,
@@ -6,7 +6,7 @@ import React from 'react';
6
6
  export const ModalTitle = _ref => {
7
7
  let {
8
8
  children,
9
- dataTest
9
+ dataTest = 'dhis2-uicore-modaltitle'
10
10
  } = _ref;
11
11
  return /*#__PURE__*/React.createElement("h1", {
12
12
  "data-test": dataTest,
@@ -16,9 +16,6 @@ export const ModalTitle = _ref => {
16
16
  dynamic: [colors.grey900, spacers.dp12]
17
17
  }, [`h1.__jsx-style-dynamic-selector{-webkit-order:1;-ms-flex-order:1;order:1;-webkit-align-self:flex-start;-ms-flex-item-align:start;align-self:flex-start;color:${colors.grey900};font-size:20px;font-weight:500;line-height:24px;margin:0 0 ${spacers.dp12};}`]));
18
18
  };
19
- ModalTitle.defaultProps = {
20
- dataTest: 'dhis2-uicore-modaltitle'
21
- };
22
19
  ModalTitle.propTypes = {
23
20
  children: PropTypes.node,
24
21
  dataTest: PropTypes.string
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhis2-ui/modal",
3
- "version": "9.11.3",
3
+ "version": "9.11.5",
4
4
  "description": "UI Modal",
5
5
  "repository": {
6
6
  "type": "git",
@@ -33,12 +33,12 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@dhis2/prop-types": "^3.1.2",
36
- "@dhis2-ui/card": "9.11.3",
37
- "@dhis2-ui/center": "9.11.3",
38
- "@dhis2-ui/layer": "9.11.3",
39
- "@dhis2-ui/portal": "9.11.3",
40
- "@dhis2/ui-constants": "9.11.3",
41
- "@dhis2/ui-icons": "9.11.3",
36
+ "@dhis2-ui/card": "9.11.5",
37
+ "@dhis2-ui/center": "9.11.5",
38
+ "@dhis2-ui/layer": "9.11.5",
39
+ "@dhis2-ui/portal": "9.11.5",
40
+ "@dhis2/ui-constants": "9.11.5",
41
+ "@dhis2/ui-icons": "9.11.5",
42
42
  "classnames": "^2.3.1",
43
43
  "prop-types": "^15.7.2"
44
44
  },