@ndlib/component-library 0.0.43 → 0.0.44

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.
@@ -20,6 +20,13 @@ const ModalExample = () => {
20
20
  isPrimary: false,
21
21
  onClick: () => { },
22
22
  },
23
+ {
24
+ label: 'Customized',
25
+ onClick: () => { },
26
+ buttonProps: {
27
+ loading: true,
28
+ },
29
+ },
23
30
  {
24
31
  label: 'Primary',
25
32
  isPrimary: true,
@@ -1,5 +1,6 @@
1
1
  import { StyledElementProps } from '../../../theme';
2
2
  import React from 'react';
3
+ import { ButtonProps } from '../../elements/Button';
3
4
  type ModalProps = StyledElementProps<HTMLDivElement, {
4
5
  isOpen: boolean;
5
6
  close: (e: React.MouseEvent) => void;
@@ -12,6 +13,7 @@ type ModalProps = StyledElementProps<HTMLDivElement, {
12
13
  type ModalAction = {
13
14
  label: string;
14
15
  isPrimary?: boolean;
16
+ buttonProps?: Partial<ButtonProps>;
15
17
  onClick: (e: React.MouseEvent) => void;
16
18
  };
17
19
  export declare const Modal: React.FC<ModalProps>;
@@ -42,7 +42,7 @@ export const Modal = (_a) => {
42
42
  action.onClick(e);
43
43
  }, sx: {
44
44
  mr: index < actions.length - 1 ? 1 : 0,
45
- } }, { children: action.label }), index))) })))] })))] })));
45
+ } }, action.buttonProps, { children: action.label }), index))) })))] })))] })));
46
46
  return (_jsx(ReactModal, Object.assign({ isOpen: isOpen, shouldFocusAfterRender: true, appElement: modal.appElement, onRequestClose: (e) => {
47
47
  e.preventDefault();
48
48
  e.stopPropagation();
@@ -12,7 +12,7 @@ export declare enum BUTTON_TYPE {
12
12
  TEXT = "text",
13
13
  OUTLINE = "outline"
14
14
  }
15
- type ButtonProps = StyledElementProps<HTMLButtonElement, {
15
+ export type ButtonProps = StyledElementProps<HTMLButtonElement, {
16
16
  size?: BUTTON_SIZE;
17
17
  type?: BUTTON_TYPE;
18
18
  color?: COLOR;
@@ -6,3 +6,4 @@ type Story = StoryObj<typeof TextInput>;
6
6
  export declare const Default: Story;
7
7
  export declare const WithLabel: Story;
8
8
  export declare const Inverted: Story;
9
+ export declare const Disabled: Story;
@@ -30,3 +30,6 @@ export const WithLabel = {
30
30
  export const Inverted = {
31
31
  render: () => (_jsx(Column, Object.assign({ sx: { backgroundColor: COLOR.BLACK, p: 2 } }, { children: sizes.map((size) => (_jsxs(Group, { children: [_jsx(Heading, Object.assign({ size: HEADING_SIZE.MD, sx: { color: COLOR.WHITE } }, { children: size.label })), _jsx(StatefulInput, { inverted: true, size: size.size, leftIcon: SearchIcon, placeholder: "Placeholder", label: "Search", sx: { mt: 2 } })] }))) }))),
32
32
  };
33
+ export const Disabled = {
34
+ render: () => (_jsx(Column, Object.assign({ sx: { p: 2 } }, { children: sizes.map((size) => (_jsxs(Group, { children: [_jsx(Heading, Object.assign({ size: HEADING_SIZE.MD, sx: { color: COLOR.WHITE } }, { children: size.label })), _jsx(StatefulInput, { disabled: true, size: size.size, leftIcon: SearchIcon, placeholder: "Placeholder", label: "Search", sx: { mt: 2 } })] }))) }))),
35
+ };
@@ -23,6 +23,7 @@ export type TextInputProps = StyledElementProps<HTMLInputElement, {
23
23
  inline?: boolean;
24
24
  inverted?: boolean;
25
25
  label?: string;
26
+ disabled?: boolean;
26
27
  value: string;
27
28
  onChange?: (value: string) => void;
28
29
  onChangeRaw?: (e: string | React.ChangeEvent) => void;
@@ -36,6 +37,7 @@ export declare const TextInput: React.ForwardRefExoticComponent<{
36
37
  inline?: boolean | undefined;
37
38
  inverted?: boolean | undefined;
38
39
  label?: string | undefined;
40
+ disabled?: boolean | undefined;
39
41
  value: string;
40
42
  onChange?: ((value: string) => void) | undefined;
41
43
  onChangeRaw?: ((e: string | React.ChangeEvent) => void) | undefined;
@@ -50,7 +50,7 @@ const defaultHeight = {
50
50
  [INPUT_SIZE.LG]: '3rem',
51
51
  };
52
52
  export const TextInput = React.forwardRef((_a, ref) => {
53
- var { value, label, onChange, onChangeRaw, onClick, inline, inverted, size: sizeParam, leftIcon, sx } = _a, rest = __rest(_a, ["value", "label", "onChange", "onChangeRaw", "onClick", "inline", "inverted", "size", "leftIcon", "sx"]);
53
+ var { value, label, onChange, onChangeRaw, onClick, inline, inverted, size: sizeParam, leftIcon, sx, disabled } = _a, rest = __rest(_a, ["value", "label", "onChange", "onChangeRaw", "onClick", "inline", "inverted", "size", "leftIcon", "sx", "disabled"]);
54
54
  const id = useUniqueHtmlId('text-input');
55
55
  const theme = useTheme();
56
56
  const size = sizeParam || INPUT_SIZE.MD;
@@ -59,9 +59,13 @@ export const TextInput = React.forwardRef((_a, ref) => {
59
59
  const height = defaultHeight[size];
60
60
  const typography = typographyMap[size];
61
61
  const typographyStyles = getTypographyStyles(typography);
62
- const focusStyles = {
63
- boxShadow: inverted ? theme.boxShadow.INVERTED : theme.boxShadow.NORMAL,
64
- };
62
+ const focusStyles = disabled
63
+ ? {}
64
+ : {
65
+ boxShadow: inverted
66
+ ? theme.boxShadow.INVERTED
67
+ : theme.boxShadow.NORMAL,
68
+ };
65
69
  return (_jsxs("div", Object.assign({ ref: ref, onClick: onClick, id: id, sx: Object.assign(Object.assign({ height,
66
70
  display, px: paddingX, backgroundColor: inverted ? COLOR.DARK_GRAY : COLOR.WHITE, borderRadius: '4px', flexDirection: 'row', position: 'relative', alignItems: 'center', ':hover': focusStyles, ':focus': focusStyles }, typographyStyles), sx) }, { children: [_jsx("fieldset", Object.assign({ sx: {
67
71
  textAlign: 'left',
@@ -104,7 +108,7 @@ export const TextInput = React.forwardRef((_a, ref) => {
104
108
  color: inverted ? COLOR.LIGHT_GRAY : COLOR.GRAY,
105
109
  }, ':focus': {
106
110
  outline: 'none',
107
- } }) }, rest)), label && (_jsx(Label, Object.assign({ htmlFor: id, typography: labelTypographyMap[size], sx: {
111
+ } }), disabled: disabled }, rest)), label && (_jsx(Label, Object.assign({ htmlFor: id, typography: labelTypographyMap[size], sx: {
108
112
  position: 'absolute',
109
113
  color: inverted ? COLOR.EXTRA_LIGHT_GRAY : COLOR.ND_PROVOST_BLUE,
110
114
  left: '0.5rem',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ndlib/component-library",
3
- "version": "0.0.43",
3
+ "version": "0.0.44",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "files": [