ag-common 0.0.243 → 0.0.246

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.
@@ -58,6 +58,7 @@ const DropItems = styled_components_1.default.div `
58
58
  &[data-open='true'] {
59
59
  display: flex;
60
60
  }
61
+ ${(0, common_1.bounce)('data-bounced')}
61
62
  `;
62
63
  const ListItemStyle = styled_components_1.default.div `
63
64
  z-index: 1;
@@ -70,14 +71,16 @@ const ListItemStyle = styled_components_1.default.div `
70
71
  overflow: hidden;
71
72
  justify-content: center;
72
73
  align-items: center;
73
- &[data-selected='true'] {
74
- opacity: 1 !important;
75
- background-color: ${colours_1.colours.orangeRed} !important;
76
- }
77
- &[data-selected='false'] {
78
- &:hover {
79
- opacity: 0.9 !important;
80
- background-color: ${colours_1.colours.orange} !important;
74
+ &[data-default='false'] {
75
+ &[data-selected='true'] {
76
+ opacity: 1 !important;
77
+ background-color: ${colours_1.colours.orangeRed} !important;
78
+ }
79
+ &[data-selected='false'] {
80
+ &:hover {
81
+ opacity: 0.9 !important;
82
+ background-color: ${colours_1.colours.orange} !important;
83
+ }
81
84
  }
82
85
  }
83
86
 
@@ -88,7 +91,7 @@ const ListItemStyle = styled_components_1.default.div `
88
91
  background-color: rgba(0, 0, 0, 0.2);
89
92
  }
90
93
  `;
91
- const ListItem = ({ render, onChange, selected, }) => (react_1.default.createElement(ListItemStyle, { "data-selected": selected, onClick: (e) => {
94
+ const ListItem = ({ render, onChange, selected, defaultV = false, }) => (react_1.default.createElement(ListItemStyle, { "data-selected": selected, "data-default": defaultV, onClick: (e) => {
92
95
  if (!selected) {
93
96
  onChange === null || onChange === void 0 ? void 0 : onChange();
94
97
  }
@@ -99,8 +102,10 @@ function DropdownList(p) {
99
102
  const ref = (0, react_1.useRef)(null);
100
103
  const [state, setState] = (0, react_1.useState)(value);
101
104
  const [open, setOpen] = (0, react_1.useState)(false);
105
+ const [bounced, setBounced] = (0, react_1.useState)(false);
102
106
  (0, useOnClickOutside_1.useOnClickOutside)({ disabled: !open, ref, moveMouseOutside: false }, () => {
103
107
  setOpen(false);
108
+ setBounced(false);
104
109
  });
105
110
  (0, react_1.useEffect)(() => {
106
111
  const newv = value;
@@ -138,13 +143,18 @@ function DropdownList(p) {
138
143
  }, [open, options, renderF, style]);
139
144
  const defaultRender = !p.value ? react_1.default.createElement(KebabDots_1.KebabDots, null) : react_1.default.createElement(react_1.default.Fragment, null, p.renderF(p.value));
140
145
  const defaultKey = !p.value ? '(noval)' : p.renderF(p.value);
141
- const openDisplay = p.children || (react_1.default.createElement(ListItem, { selected: true, render: defaultRender, key: defaultKey }));
146
+ const openDisplay = p.children || (react_1.default.createElement(ListItem, { selected: true, render: defaultRender, key: defaultKey, defaultV: !p.value }));
147
+ (0, react_1.useEffect)(() => {
148
+ if (!bounced && open) {
149
+ setBounced(true);
150
+ }
151
+ }, [bounced, open]);
142
152
  return (react_1.default.createElement(SBase, { className: className, ref: ref, title: placeholder, onClick: (e) => {
143
153
  e.stopPropagation();
144
154
  e.preventDefault();
145
155
  setOpen(!open);
146
156
  } },
147
- react_1.default.createElement(DropItems, { "data-open": open, style: style, shadow: shadow, maxHeight: maxHeight }, open &&
157
+ react_1.default.createElement(DropItems, { "data-open": open, style: style, shadow: shadow, maxHeight: maxHeight, "data-bounced": bounced }, open &&
148
158
  options.map((s, i) => (react_1.default.createElement(ListItem, { key: p.renderF(s), render: p.renderF(s), onChange: () => p.onChange(s, i), selected: s === state })))),
149
159
  openDisplay));
150
160
  }
@@ -11,7 +11,6 @@ const Dots = (react_1.default.createElement("svg", { viewBox: "0 0 24 24", xmlns
11
11
  react_1.default.createElement("path", { d: "M16 12a3.001 3.001 0 016 0 3.001 3.001 0 01-6 0zm1 0a2 2 0 114.001.001A2 2 0 0117 12zm-8 0a3.001 3.001 0 016 0 3.001 3.001 0 01-6 0zm1 0a2 2 0 114.001.001A2 2 0 0110 12zm-8 0a3.001 3.001 0 016 0 3.001 3.001 0 01-6 0zm1 0a2 2 0 114.001.001A2 2 0 013 12z" })));
12
12
  const IconStyled = (0, styled_components_1.default)(Icon_1.Icon) `
13
13
  position: absolute;
14
- background-color: white;
15
14
  `;
16
15
  const KebabDots = ({ onClick }) => (react_1.default.createElement(IconStyled, { width: "2rem", height: "2rem", onClick: () => onClick === null || onClick === void 0 ? void 0 : onClick() }, Dots));
17
16
  exports.KebabDots = KebabDots;
@@ -29,6 +29,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.Modal = exports.ModalItem = void 0;
30
30
  const Close_1 = require("../Close");
31
31
  const useOnClickOutside_1 = require("../../helpers/useOnClickOutside");
32
+ const styles_1 = require("../../styles");
32
33
  const react_1 = __importStar(require("react"));
33
34
  const styled_components_1 = __importDefault(require("styled-components"));
34
35
  const FixedBackground = styled_components_1.default.div `
@@ -65,6 +66,7 @@ const ModalBase = styled_components_1.default.div `
65
66
  &[data-topposition='bottom'] {
66
67
  bottom: 0;
67
68
  }
69
+ ${(0, styles_1.bounce)('data-bounced')}
68
70
  `;
69
71
  exports.ModalItem = styled_components_1.default.div `
70
72
  display: flex;
@@ -78,6 +80,7 @@ const CloseStyled = (0, styled_components_1.default)(Close_1.Close) `
78
80
  z-index: 1;
79
81
  `;
80
82
  const Modal = ({ open, setOpen, children, position = 'left', topPosition = 'top', showCloseButton = true, closeOnMoveMouseOutside = false, className, closeOnClickOutside = true, }) => {
83
+ const [bounced, setBounced] = (0, react_1.useState)(false);
81
84
  const ref = (0, react_1.useRef)(null);
82
85
  (0, useOnClickOutside_1.useOnClickOutside)({
83
86
  disabled: !open,
@@ -86,13 +89,19 @@ const Modal = ({ open, setOpen, children, position = 'left', topPosition = 'top'
86
89
  }, () => {
87
90
  if (closeOnClickOutside && open) {
88
91
  setOpen(false);
92
+ setBounced(false);
89
93
  }
90
94
  });
95
+ (0, react_1.useEffect)(() => {
96
+ if (!bounced && open) {
97
+ setBounced(true);
98
+ }
99
+ }, [open, bounced]);
91
100
  if (!open) {
92
101
  return react_1.default.createElement(react_1.default.Fragment, null);
93
102
  }
94
103
  return (react_1.default.createElement(FixedBackground, null,
95
- react_1.default.createElement(ModalBase, { "data-position": position, "data-topposition": topPosition, ref: ref, className: className },
104
+ react_1.default.createElement(ModalBase, { "data-bounced": bounced, "data-position": position, "data-topposition": topPosition, ref: ref, className: className },
96
105
  showCloseButton && react_1.default.createElement(CloseStyled, { onClick: () => setOpen(false) }),
97
106
  children)));
98
107
  };
@@ -6,18 +6,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getFetchCall = void 0;
7
7
  const common_1 = require("../../helpers/common");
8
8
  const react_1 = __importDefault(require("react"));
9
- const styled_components_1 = __importDefault(require("styled-components"));
10
- const rb = react_1.default.createElement(react_1.default.Fragment, null, "}");
11
- const lb = react_1.default.createElement(react_1.default.Fragment, null, "{");
12
- const Lpad = styled_components_1.default.div `
13
- padding-left: 0.5rem;
14
- `;
15
9
  const getFetchCall = (p, ops) => {
16
10
  return (react_1.default.createElement(react_1.default.Fragment, null,
17
11
  react_1.default.createElement(common_1.Highlight, null, "const"),
18
12
  "\u00A0response = ",
19
13
  react_1.default.createElement(common_1.Highlight, null, "await"),
20
14
  ' ',
21
- react_1.default.createElement(common_1.Highlight2, null, "fetch")));
15
+ react_1.default.createElement(common_1.Highlight2, null, "fetch"),
16
+ "(",
17
+ react_1.default.createElement(common_1.Highlight, null,
18
+ "'",
19
+ ops.fullApiUrl,
20
+ "'"),
21
+ ",\u00A0 requestOptions);"));
22
22
  };
23
23
  exports.getFetchCall = getFetchCall;
@@ -14,3 +14,4 @@ export declare const noDrag: {
14
14
  onTouchStart: React.TouchEventHandler<HTMLDivElement>;
15
15
  };
16
16
  export declare const FullScreenPage: import("styled-components").StyledComponent<"div", any, {}, never>;
17
+ export declare const bounce: (bounceattr: string) => import("styled-components").FlattenSimpleInterpolation;
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.FullScreenPage = exports.noDrag = exports.Card = exports.FadeBottom = exports.CssTransparentBlock = exports.TextOverflowEllipsis = exports.NoTextSelect = exports.Shadow = exports.HardOutline = void 0;
26
+ exports.bounce = exports.FullScreenPage = exports.noDrag = exports.Card = exports.FadeBottom = exports.CssTransparentBlock = exports.TextOverflowEllipsis = exports.NoTextSelect = exports.Shadow = exports.HardOutline = void 0;
27
27
  const colours_1 = require("./colours");
28
28
  const styled_components_1 = __importStar(require("styled-components"));
29
29
  const HardOutline = (colour) => (0, styled_components_1.css) `
@@ -116,3 +116,13 @@ exports.FullScreenPage = styled_components_1.default.div `
116
116
  align-content: flex-start;
117
117
  align-items: flex-start;
118
118
  `;
119
+ const bounce = (bounceattr) => (0, styled_components_1.css) `
120
+ transition: opacity 0.2s ease,
121
+ transform 0.2s cubic-bezier(0.02, 1.5, 0.74, 1.23);
122
+ transform-origin: 50% 50%;
123
+ transform: translateY(-5px);
124
+ &[${bounceattr}='true'] {
125
+ transform: translateY(0);
126
+ }
127
+ `;
128
+ exports.bounce = bounce;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ag-common",
3
- "version": "0.0.243",
3
+ "version": "0.0.246",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "author": "Andrei Gec <@andreigec> (https://gec.dev/)",
@@ -30,7 +30,7 @@
30
30
  "typescript": "4.x"
31
31
  },
32
32
  "devDependencies": {
33
- "@babel/core": "7.17.9",
33
+ "@babel/core": "7.17.10",
34
34
  "@storybook/addon-actions": "6.4.22",
35
35
  "@storybook/addon-docs": "6.4.22",
36
36
  "@storybook/addon-essentials": "6.4.22",
@@ -40,14 +40,14 @@
40
40
  "@storybook/react": "6.4.22",
41
41
  "@storybook/theming": "6.4.22",
42
42
  "@types/jsonwebtoken": "8.5.8",
43
- "@types/node": "17.0.29",
43
+ "@types/node": "17.0.32",
44
44
  "@types/react": "17.0.43",
45
45
  "@types/react-dom": "17.0.14",
46
46
  "@types/styled-components": "5.1.25",
47
- "@typescript-eslint/eslint-plugin": "5.21.0",
48
- "@typescript-eslint/parser": "5.21.0",
47
+ "@typescript-eslint/eslint-plugin": "5.23.0",
48
+ "@typescript-eslint/parser": "5.23.0",
49
49
  "cross-env": "7.0.3",
50
- "eslint": "8.14.0",
50
+ "eslint": "8.15.0",
51
51
  "eslint-config-airbnb-typescript": "17.0.0",
52
52
  "eslint-config-prettier": "8.5.0",
53
53
  "eslint-plugin-import": "2.26.0",