@dtdot/lego 0.17.20 → 0.17.23

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.
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ import { ColourVariant } from '../../theme/theme.types';
3
+ export interface ActionMenuProps {
4
+ variant?: ColourVariant;
5
+ }
6
+ declare const ActionMenu: ({ variant }: ActionMenuProps) => JSX.Element;
7
+ export default ActionMenu;
@@ -0,0 +1,13 @@
1
+ import { faEllipsisV } from '@fortawesome/free-solid-svg-icons';
2
+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
3
+ import React from 'react';
4
+ import styled from 'styled-components';
5
+ import Button from '../Button/Button.component';
6
+ const StyledIcon = styled(FontAwesomeIcon) `
7
+ font-size: 18px;
8
+ `;
9
+ const ActionMenu = ({ variant }) => {
10
+ return (React.createElement(Button, { variant: variant },
11
+ React.createElement(StyledIcon, { icon: faEllipsisV })));
12
+ };
13
+ export default ActionMenu;
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ import { Meta } from '@storybook/react/types-6-0';
3
+ export declare const Standard: () => JSX.Element;
4
+ export declare const Variants: () => JSX.Element;
5
+ declare const _default: Meta<import("@storybook/react/types-6-0").Args>;
6
+ export default _default;
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import { ActionMenu } from '../..';
3
+ /* eslint-disable @typescript-eslint/no-empty-function */
4
+ export const Standard = () => React.createElement(ActionMenu, null);
5
+ export const Variants = () => (React.createElement(React.Fragment, null,
6
+ React.createElement(ActionMenu, { variant: 'primary' }),
7
+ React.createElement("br", null),
8
+ React.createElement("br", null),
9
+ React.createElement(ActionMenu, { variant: 'secondary' }),
10
+ React.createElement("br", null),
11
+ React.createElement("br", null),
12
+ React.createElement(ActionMenu, { variant: 'tertiary' })));
13
+ export default {
14
+ title: 'Components/ActionMenu',
15
+ component: ActionMenu,
16
+ };
@@ -4,6 +4,7 @@ import getThemeVariantColours from '../../theme/helpers/getThemeVariantColours';
4
4
  import { BadgeSpan } from '../Badge/Badge.component';
5
5
  const InteractiveBadge = styled(BadgeSpan) `
6
6
  cursor: pointer;
7
+ margin-bottom: 8px;
7
8
 
8
9
  ${(props) => props.inactive &&
9
10
  `
@@ -12,6 +13,9 @@ const InteractiveBadge = styled(BadgeSpan) `
12
13
  `}
13
14
  `;
14
15
  const BadgeSelectorOuter = styled.div `
16
+ display: flex;
17
+ flex-wrap: wrap;
18
+
15
19
  ${InteractiveBadge} {
16
20
  margin-right: 8px;
17
21
  }
@@ -1,5 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { Meta } from '@storybook/react/types-6-0';
3
3
  export declare const Standard: () => JSX.Element;
4
+ export declare const LotsOfBadges: () => JSX.Element;
4
5
  declare const _default: Meta<import("@storybook/react/types-6-0").Args>;
5
6
  export default _default;
@@ -27,6 +27,67 @@ export const Standard = () => {
27
27
  const [value, setValue] = useState(['pending']);
28
28
  return React.createElement(BadgeSelector, { options: options, value: value, onChange: setValue });
29
29
  };
30
+ const options2 = [
31
+ {
32
+ value: 'one',
33
+ name: 'one',
34
+ variant: 'info',
35
+ },
36
+ {
37
+ value: 'two',
38
+ name: 'two',
39
+ variant: 'info',
40
+ },
41
+ {
42
+ value: 'three',
43
+ name: 'three',
44
+ variant: 'info',
45
+ },
46
+ {
47
+ value: 'four',
48
+ name: 'four',
49
+ variant: 'info',
50
+ },
51
+ {
52
+ value: 'five',
53
+ name: 'five',
54
+ variant: 'info',
55
+ },
56
+ {
57
+ value: 'six',
58
+ name: 'six',
59
+ variant: 'info',
60
+ },
61
+ {
62
+ value: 'seven',
63
+ name: 'seven',
64
+ variant: 'info',
65
+ },
66
+ {
67
+ value: 'eight',
68
+ name: 'eight',
69
+ variant: 'info',
70
+ },
71
+ {
72
+ value: 'nine',
73
+ name: 'nine',
74
+ variant: 'info',
75
+ },
76
+ {
77
+ value: 'ten',
78
+ name: 'ten',
79
+ variant: 'info',
80
+ },
81
+ {
82
+ value: 'eleven',
83
+ name: 'eleven',
84
+ variant: 'info',
85
+ },
86
+ ];
87
+ export const LotsOfBadges = () => {
88
+ const [value, setValue] = useState(['one']);
89
+ return React.createElement(BadgeSelector, { options: options2, value: value, onChange: setValue });
90
+ };
30
91
  export default {
31
92
  title: 'Components/BadgeSelector',
32
93
  component: BadgeSelector,
@@ -1,3 +1,4 @@
1
+ export declare const getValue: <T = string>(value: T, contextValue: T) => T;
1
2
  declare function useFormNode<T = string, K = string>(key?: string): {
2
3
  value: undefined;
3
4
  error: undefined;
@@ -1,5 +1,11 @@
1
1
  import { useContext } from 'react';
2
2
  import FormStateContext from './FormState.context';
3
+ export const getValue = (value, contextValue) => {
4
+ if (value !== null && value !== undefined) {
5
+ return value;
6
+ }
7
+ return contextValue;
8
+ };
3
9
  function useFormNode(key) {
4
10
  const { value, errors, onChange } = useContext(FormStateContext);
5
11
  if (!key) {
@@ -6,6 +6,7 @@ export interface IInputProps {
6
6
  label?: string;
7
7
  placeholder?: string;
8
8
  type?: string;
9
+ autoFocus?: boolean;
9
10
  value?: string;
10
11
  error?: string;
11
12
  onChange?: (value: any) => void;
@@ -5,7 +5,7 @@ import { motion } from 'framer-motion';
5
5
  import React, { useState } from 'react';
6
6
  import styled, { css } from 'styled-components';
7
7
  import getThemeControlColours from '../../theme/helpers/getThemeControlColours';
8
- import useFormNode from '../Form/useFormNode.hook';
8
+ import useFormNode, { getValue } from '../Form/useFormNode.hook';
9
9
  export const INPUT_HEIGHT = 48;
10
10
  const InputContainer = styled(motion.div) `
11
11
  position: relative;
@@ -93,7 +93,7 @@ const messageVariants = {
93
93
  errorFocus: { opacity: 1, y: -4 },
94
94
  };
95
95
  const Input = React.forwardRef(function ForwardRefInput(props, ref) {
96
- const { label, name, placeholder, type = 'text', value, error: propsError, onChange, onFocus, onBlur } = props;
96
+ const { label, name, placeholder, type = 'text', autoFocus, value, error: propsError, onChange, onFocus, onBlur, } = props;
97
97
  const [isFocused, setIsFocused] = useState(false);
98
98
  const { value: contextValue, error: contextError, onChange: contextOnChange } = useFormNode(name);
99
99
  const error = contextError || propsError;
@@ -120,7 +120,7 @@ const Input = React.forwardRef(function ForwardRefInput(props, ref) {
120
120
  return (React.createElement("div", null,
121
121
  label && React.createElement(InputLabel, { htmlFor: name }, label),
122
122
  React.createElement(InputContainer, { animate: error ? (isFocused ? 'errorFocus' : 'error') : undefined },
123
- React.createElement(StyledInput, { ref: ref, variants: inputVariants, transition: { type: 'spring', duration: 0.3 }, type: type, name: name, placeholder: placeholder, value: value || contextValue, onChange: handleChange, onFocus: handleFocus, onBlur: handleBlur }),
123
+ React.createElement(StyledInput, { ref: ref, variants: inputVariants, transition: { type: 'spring', duration: 0.3 }, type: type, name: name, placeholder: placeholder, value: getValue(value, contextValue), onChange: handleChange, onFocus: handleFocus, onBlur: handleBlur, autoFocus: autoFocus }),
124
124
  React.createElement(ErrorContainer, { animate: error ? 'show' : undefined, style: { opacity: 0 }, variants: errorVariants, transition: { type: 'spring', duration: 0.3 } },
125
125
  React.createElement(ErrorInner, null,
126
126
  React.createElement(FontAwesomeIcon, { icon: faExclamationCircle }))),
@@ -20,7 +20,8 @@ const TableCell = styled.td `
20
20
  const Table = ({ children, variant = 'regular' }) => {
21
21
  return (React.createElement(TableContext.Provider, { value: { variant } },
22
22
  React.createElement(ButtonContext.Provider, { value: { height: '24px' } },
23
- React.createElement(StyledTable, null, children))));
23
+ React.createElement(StyledTable, null,
24
+ React.createElement("tbody", null, children)))));
24
25
  };
25
26
  Table.Row = TableRow;
26
27
  Table.Cell = TableCell;
package/build/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { default as BodyStyle } from './global/BodyStyle.component';
2
+ export { default as ActionMenu } from './components/ActionMenu/ActionMenu.component';
2
3
  export { default as ActionMessage } from './components/ActionMessage/ActionMessage.component';
3
4
  export { default as Alert } from './components/Alert/Alert.component';
4
5
  export { default as Badge } from './components/Badge/Badge.component';
package/build/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export { default as BodyStyle } from './global/BodyStyle.component';
2
+ export { default as ActionMenu } from './components/ActionMenu/ActionMenu.component';
2
3
  export { default as ActionMessage } from './components/ActionMessage/ActionMessage.component';
3
4
  export { default as Alert } from './components/Alert/Alert.component';
4
5
  export { default as Badge } from './components/Badge/Badge.component';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dtdot/lego",
3
- "version": "0.17.20",
3
+ "version": "0.17.23",
4
4
  "description": "Some reusable components for building my applications",
5
5
  "main": "build/index.js",
6
6
  "scripts": {