@dtdot/lego 0.17.20 → 0.17.21

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.
@@ -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) {
@@ -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;
@@ -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 }),
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dtdot/lego",
3
- "version": "0.17.20",
3
+ "version": "0.17.21",
4
4
  "description": "Some reusable components for building my applications",
5
5
  "main": "build/index.js",
6
6
  "scripts": {