chop-logic-components 0.13.0 → 1.0.2

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.
Files changed (76) hide show
  1. package/README.md +49 -1
  2. package/dist/components/containers/form/Form.d.ts +2 -8
  3. package/dist/components/containers/form/FormContext.d.ts +1 -15
  4. package/dist/components/containers/form/__docs__/FormExample.d.ts +1 -1
  5. package/dist/components/containers/form/controller.d.ts +1 -1
  6. package/dist/components/containers/form/helpers.d.ts +1 -1
  7. package/dist/components/containers/form/types.d.ts +23 -0
  8. package/dist/components/containers/grid/controller.d.ts +16 -0
  9. package/dist/components/containers/grid/elements/Checkbox.d.ts +2 -2
  10. package/dist/components/containers/tabs/Tabs.d.ts +1 -12
  11. package/dist/components/containers/tabs/Tabs.styled.d.ts +1 -1
  12. package/dist/components/containers/tabs/elements/TabButton.d.ts +1 -1
  13. package/dist/components/containers/tabs/elements/TabContent.d.ts +3 -4
  14. package/dist/components/containers/tabs/elements/TabList.d.ts +1 -1
  15. package/dist/components/containers/tabs/types.d.ts +13 -0
  16. package/dist/components/inputs/_common/input-inner-button/InputInnerButton.d.ts +2 -2
  17. package/dist/components/inputs/button/Button.d.ts +2 -11
  18. package/dist/components/inputs/button/Button.styled.d.ts +1 -1
  19. package/dist/components/inputs/button/__docs__/ButtonExample.d.ts +1 -1
  20. package/dist/components/inputs/button/types.d.ts +12 -0
  21. package/dist/components/inputs/checkbox/Checkbox.d.ts +1 -6
  22. package/dist/components/inputs/checkbox/__docs__/CheckboxExample.d.ts +1 -1
  23. package/dist/components/inputs/checkbox/controller.d.ts +9 -0
  24. package/dist/components/inputs/checkbox/helpers.d.ts +6 -8
  25. package/dist/components/inputs/checkbox/types.d.ts +7 -0
  26. package/dist/components/inputs/multi-select/MultiSelect.d.ts +1 -18
  27. package/dist/components/inputs/multi-select/__docs__/MultiSelectExample.d.ts +1 -1
  28. package/dist/components/inputs/multi-select/controller.d.ts +15 -0
  29. package/dist/components/inputs/multi-select/elements/Combobox.d.ts +1 -1
  30. package/dist/components/inputs/multi-select/elements/Dropdown.d.ts +1 -1
  31. package/dist/components/inputs/multi-select/elements/Option.d.ts +1 -1
  32. package/dist/components/inputs/multi-select/helpers.d.ts +5 -15
  33. package/dist/components/inputs/multi-select/types.d.ts +19 -0
  34. package/dist/components/inputs/numeric/NumericInput.d.ts +1 -10
  35. package/dist/components/inputs/numeric/__docs__/NumericInputExample.d.ts +1 -1
  36. package/dist/components/inputs/numeric/controller.d.ts +22 -0
  37. package/dist/components/inputs/numeric/helpers.d.ts +2 -22
  38. package/dist/components/inputs/numeric/types.d.ts +11 -0
  39. package/dist/components/inputs/select/Select.d.ts +2 -14
  40. package/dist/components/inputs/select/__docs__/SelectExample.d.ts +1 -1
  41. package/dist/components/inputs/select/controller.d.ts +15 -0
  42. package/dist/components/inputs/select/elements/Combobox.d.ts +1 -1
  43. package/dist/components/inputs/select/elements/Dropdown.d.ts +1 -1
  44. package/dist/components/inputs/select/elements/Option.d.ts +1 -7
  45. package/dist/components/inputs/select/helpers.d.ts +2 -15
  46. package/dist/components/inputs/select/types.d.ts +20 -0
  47. package/dist/components/inputs/text/TextInput.d.ts +1 -15
  48. package/dist/components/inputs/text/__docs__/TextInputExample.d.ts +1 -1
  49. package/dist/components/inputs/text/controller.d.ts +18 -0
  50. package/dist/components/inputs/text/helpers.d.ts +2 -18
  51. package/dist/components/inputs/text/types.d.ts +15 -0
  52. package/dist/components/misc/icon/Icon.d.ts +2 -2
  53. package/dist/components/modals/alert/Alert.d.ts +1 -10
  54. package/dist/components/modals/alert/__docs__/Alert.stories.d.ts +1 -1
  55. package/dist/components/modals/alert/elements/Header.d.ts +1 -8
  56. package/dist/components/modals/alert/helpers.d.ts +5 -0
  57. package/dist/components/modals/alert/types.d.ts +17 -0
  58. package/dist/components/modals/dialog/Dialog.d.ts +2 -7
  59. package/dist/components/modals/dialog/__docs__/DialogExample.d.ts +2 -2
  60. package/dist/components/modals/dialog/elements/Header.d.ts +2 -3
  61. package/dist/components/modals/dialog/elements/Layout.d.ts +3 -7
  62. package/dist/components/modals/dialog/types.d.ts +12 -0
  63. package/dist/components/modals/tooltip/Tooltip.d.ts +1 -6
  64. package/dist/components/modals/tooltip/__docs__/TooltipExample.d.ts +1 -1
  65. package/dist/components/modals/tooltip/controller.d.ts +15 -0
  66. package/dist/components/modals/tooltip/types.d.ts +8 -0
  67. package/dist/constants/style-variables.d.ts +3 -3
  68. package/dist/index.cjs.js +91 -91
  69. package/dist/index.cjs.js.map +1 -1
  70. package/dist/index.es.js +2830 -3357
  71. package/dist/index.es.js.map +1 -1
  72. package/package.json +2 -2
  73. package/dist/components/modals/alert/helpers/get-alert-title.d.ts +0 -3
  74. package/dist/components/modals/alert/helpers/render-alert-icon.d.ts +0 -4
  75. package/dist/utils/__tests__/create-class-name.test.d.ts +0 -1
  76. package/dist/utils/create-class-name.d.ts +0 -6
package/README.md CHANGED
@@ -1,3 +1,51 @@
1
1
  # Chop Logic Components
2
2
 
3
- A library of custom React components for use in the Chop Logic project.
3
+ Welcome to **Chop Logic Components**, a comprehensive React components library packed with a variety of **styled components** and **custom hooks** that are easy to integrate into any React project.
4
+
5
+ ## About the Library
6
+
7
+ Chop Logic is designed to speed up development by providing reusable, accessible, and highly customizable components. Whether you're building complex forms, creating dynamic layouts, or managing component logic with hooks, Chop Logic has the tools to make it easier.
8
+
9
+ ### Why Choose Chop Logic?
10
+
11
+ Here's what makes Chop Logic an excellent addition to your React project:
12
+
13
+ - **Styled Components:** All components are styled using a consistent, modern design language and can easily adapt to your project's look and feel. Each component offers a flexible API, making them simple to extend and customize.
14
+
15
+ - **Custom Hooks:** Simplify your component logic by using the custom hooks provided. From managing form input to handling asynchronous data fetching, Chop Logic's hooks cover common scenarios that developers face daily.
16
+
17
+ - **Built for Reusability:** Every component and hook is designed with reusability in mind, reducing repetitive code and enabling faster development cycles.
18
+
19
+ - **Ease of Use:** Chop Logic follows best practices in API design, ensuring that components and hooks are easy to learn and work seamlessly with each other.
20
+
21
+ - **Storybook Integration:** This library includes comprehensive Storybook documentation for each component and hook, allowing you to explore usage examples, try props in real-time, and see how each feature behaves in isolation.
22
+
23
+ ## Key Features
24
+
25
+ ### Components
26
+
27
+ Chop Logic includes a wide range of styled components that are ready to use in your projects:
28
+
29
+ - **Inputs:** Beautifully styled input controllers with customization options.
30
+ - **Containers:** Easily customizable container elements like text grids, forms, and tabs.
31
+ - **Modals:** Flexible modal windows and accessible tooltips, perfect for enhancing user interactions.
32
+ - **More Components Coming Soon!**
33
+
34
+ ### Hooks
35
+
36
+ In addition to UI components, Chop Logic offers a collection of custom hooks to help you manage complex logic:
37
+
38
+ - **useModalFocusTrap:** A hook that traps focus within an open modal, ensuring accessibility compliance.
39
+ - **useKeyPress:** Easily manage keyboard interactions and trigger actions based on keypress events.
40
+ - **useContainerDimensions:** Get the dimensions of any HTML element to dynamically adjust your UI.
41
+ - **More Hooks Coming Soon!**
42
+
43
+ ## Getting Started
44
+
45
+ To get started with Chop Logic, install it via npm or yarn:
46
+
47
+ ```bash
48
+ npm install chop-logic-components
49
+ # or
50
+ yarn add chop-logic-components
51
+ ```
@@ -1,11 +1,5 @@
1
- import { default as React, PropsWithChildren } from 'react';
2
- import { ChopLogicFormData } from './FormContext';
1
+ import { default as React } from 'react';
2
+ import { ChopLogicFormProps } from './types';
3
3
 
4
- export type ChopLogicFormProps = PropsWithChildren & React.HTMLAttributes<HTMLFormElement> & {
5
- columns?: number;
6
- initialValues?: ChopLogicFormData;
7
- hasReset?: boolean;
8
- onClickSubmit?: (data: ChopLogicFormData) => void;
9
- };
10
4
  declare const ChopLogicForm: React.FC<ChopLogicFormProps>;
11
5
  export default ChopLogicForm;
@@ -1,18 +1,4 @@
1
1
  import { default as React } from 'react';
2
+ import { ChopLogicFormContextProps } from './types';
2
3
 
3
- export type ChopLogicFormData = {
4
- [key: string]: unknown;
5
- };
6
- export type ChopLogicFormValidationState = [string, boolean][];
7
- export type ChopLogicFormInput = HTMLInputElement | HTMLSelectElement;
8
- export type ChopLogicFormInputParams = {
9
- name: string;
10
- value: unknown;
11
- valid?: boolean;
12
- };
13
- export type ChopLogicFormContextProps = {
14
- onChangeFormInput?: (params: ChopLogicFormInputParams) => void;
15
- initialValues?: ChopLogicFormData;
16
- resetSignal?: number;
17
- };
18
4
  export declare const ChopLogicFormContext: React.Context<ChopLogicFormContextProps>;
@@ -1,4 +1,4 @@
1
- import { ChopLogicFormProps } from '../Form';
1
+ import { ChopLogicFormProps } from '../types';
2
2
 
3
3
  declare const FormExample: React.FC<ChopLogicFormProps>;
4
4
  export default FormExample;
@@ -1,5 +1,5 @@
1
1
  import { FormEvent } from 'react';
2
- import { ChopLogicFormData, ChopLogicFormInputParams } from './FormContext';
2
+ import { ChopLogicFormData, ChopLogicFormInputParams } from './types';
3
3
 
4
4
  export declare function useChopLogicFormController({ initialValues, onReset, onSubmit, onClickSubmit, }: {
5
5
  initialValues?: ChopLogicFormData;
@@ -1,4 +1,4 @@
1
- import { ChopLogicFormData, ChopLogicFormInputParams, ChopLogicFormValidationState } from './FormContext';
1
+ import { ChopLogicFormData, ChopLogicFormInputParams, ChopLogicFormValidationState } from './types';
2
2
 
3
3
  export declare function getInitialValidationState(data?: ChopLogicFormData): ChopLogicFormValidationState;
4
4
  export declare function updateValidationState(state: ChopLogicFormValidationState, params: ChopLogicFormInputParams): ChopLogicFormValidationState;
@@ -0,0 +1,23 @@
1
+ import { PropsWithChildren } from 'react';
2
+
3
+ export type ChopLogicFormData = {
4
+ [key: string]: unknown;
5
+ };
6
+ export type ChopLogicFormValidationState = [string, boolean][];
7
+ export type ChopLogicFormInput = HTMLInputElement | HTMLSelectElement;
8
+ export type ChopLogicFormInputParams = {
9
+ name: string;
10
+ value: unknown;
11
+ valid?: boolean;
12
+ };
13
+ export type ChopLogicFormContextProps = {
14
+ onChangeFormInput?: (params: ChopLogicFormInputParams) => void;
15
+ initialValues?: ChopLogicFormData;
16
+ resetSignal?: number;
17
+ };
18
+ export type ChopLogicFormProps = PropsWithChildren & React.HTMLAttributes<HTMLFormElement> & {
19
+ columns?: number;
20
+ initialValues?: ChopLogicFormData;
21
+ hasReset?: boolean;
22
+ onClickSubmit?: (data: ChopLogicFormData) => void;
23
+ };
@@ -0,0 +1,16 @@
1
+ import { ChopLogicGridItem } from './types';
2
+
3
+ export declare const useChopLogicGridController: ({ data, id, onSelect, }: {
4
+ data: ChopLogicGridItem[];
5
+ id?: string;
6
+ onSelect?: (ids: string[]) => void;
7
+ }) => {
8
+ elementId: string;
9
+ isAllSelected: boolean;
10
+ isAllCheckboxDisabled: boolean;
11
+ selectedIds: string[];
12
+ handleSelectAll: () => void;
13
+ handleDeselectAll: () => void;
14
+ handleSelectRowById: (id: string) => void;
15
+ handleDeselectRowById: (id: string) => void;
16
+ };
@@ -1,7 +1,7 @@
1
1
  import { default as React } from 'react';
2
2
 
3
- export type ChopLogicCheckboxProps = React.InputHTMLAttributes<HTMLInputElement> & {
3
+ type ChopLogicGridCheckboxProps = React.InputHTMLAttributes<HTMLInputElement> & {
4
4
  label: string;
5
5
  };
6
- declare const GridCheckbox: React.FC<ChopLogicCheckboxProps>;
6
+ declare const GridCheckbox: React.FC<ChopLogicGridCheckboxProps>;
7
7
  export default GridCheckbox;
@@ -1,16 +1,5 @@
1
1
  import { default as React } from 'react';
2
+ import { ChopLogicTabsProps } from './types';
2
3
 
3
- export type ChopLogicTabsProps = React.HTMLAttributes<HTMLDivElement> & {
4
- tabs: ChopLogicTabItem[];
5
- defaultTabId?: string;
6
- mode?: ChopLogicTabsMode;
7
- };
8
- export type ChopLogicTabItem = {
9
- content: React.ReactElement;
10
- title: string;
11
- id: string;
12
- disabled?: boolean;
13
- };
14
- export type ChopLogicTabsMode = 'vertical' | 'horizontal';
15
4
  declare const ChopLogicTabs: React.FC<ChopLogicTabsProps>;
16
5
  export default ChopLogicTabs;
@@ -1,4 +1,4 @@
1
- import { ChopLogicTabsMode } from './Tabs';
1
+ import { ChopLogicTabsMode } from './types';
2
2
 
3
3
  export declare const StyledTabButton: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components/dist/types').Substitute<import('react').DetailedHTMLProps<import('react').ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, {
4
4
  $selected: boolean;
@@ -1,5 +1,5 @@
1
1
  import { default as React } from 'react';
2
- import { ChopLogicTabsMode } from '../Tabs';
2
+ import { ChopLogicTabsMode } from '../types';
3
3
 
4
4
  type ChopLogicTabButtonProps = {
5
5
  title: string;
@@ -1,9 +1,8 @@
1
1
  import { default as React } from 'react';
2
- import { ChopLogicTabItem } from '../Tabs';
2
+ import { ChopLogicTabItem } from '../types';
3
3
 
4
- type ChopLogicTabContentProps = {
4
+ declare const ChopLogicTabContent: React.FC<{
5
5
  tabs: ChopLogicTabItem[];
6
6
  selectedTabId: string;
7
- };
8
- declare const ChopLogicTabContent: React.FC<ChopLogicTabContentProps>;
7
+ }>;
9
8
  export default ChopLogicTabContent;
@@ -1,5 +1,5 @@
1
1
  import { default as React } from 'react';
2
- import { ChopLogicTabItem, ChopLogicTabsMode } from '../Tabs';
2
+ import { ChopLogicTabItem, ChopLogicTabsMode } from '../types';
3
3
 
4
4
  type ChopLogicTabListProps = {
5
5
  tabs: ChopLogicTabItem[];
@@ -0,0 +1,13 @@
1
+ /// <reference types="react" />
2
+ export type ChopLogicTabsProps = React.HTMLAttributes<HTMLDivElement> & {
3
+ tabs: ChopLogicTabItem[];
4
+ defaultTabId?: string;
5
+ mode?: ChopLogicTabsMode;
6
+ };
7
+ export type ChopLogicTabItem = {
8
+ content: React.ReactElement;
9
+ title: string;
10
+ id: string;
11
+ disabled?: boolean;
12
+ };
13
+ export type ChopLogicTabsMode = 'vertical' | 'horizontal';
@@ -1,10 +1,10 @@
1
1
  import { default as React } from 'react';
2
- import { CLIcon } from '../../../../../../../../../../src/components/misc/icon/Icon';
2
+ import { ChopLogicIconName } from '../../../../../../../../../../src/components/misc/icon/Icon';
3
3
 
4
4
  type ClearInputButtonProps = {
5
5
  onClick: (event: React.MouseEvent<HTMLButtonElement>) => void;
6
6
  label: string;
7
- icon: CLIcon;
7
+ icon: ChopLogicIconName;
8
8
  };
9
9
  declare const InputInnerButton: React.FC<ClearInputButtonProps>;
10
10
  export default InputInnerButton;
@@ -1,14 +1,5 @@
1
- import { default as React, MouseEventHandler } from 'react';
2
- import { CLIcon } from '../../../../../../../../../src/components/misc/icon/Icon';
1
+ import { default as React } from 'react';
2
+ import { ChopLogicButtonProps } from './types';
3
3
 
4
- export type ChopLogicButtonView = 'primary' | 'secondary' | 'danger' | 'icon';
5
- export type ChopLogicButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {
6
- onClick?: MouseEventHandler<HTMLButtonElement> | (() => void);
7
- view?: ChopLogicButtonView;
8
- label?: string;
9
- icon?: CLIcon;
10
- text?: string;
11
- extended?: boolean;
12
- };
13
4
  declare const ChopLogicButton: React.FC<ChopLogicButtonProps>;
14
5
  export default ChopLogicButton;
@@ -1,4 +1,4 @@
1
- import { ChopLogicButtonView } from './Button';
1
+ import { ChopLogicButtonView } from './types';
2
2
 
3
3
  export declare const StyledButton: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components/dist/types').Substitute<import('react').DetailedHTMLProps<import('react').ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, {
4
4
  $view: ChopLogicButtonView;
@@ -1,5 +1,5 @@
1
1
  import { default as React } from 'react';
2
- import { ChopLogicButtonProps } from '../Button';
2
+ import { ChopLogicButtonProps } from '../types';
3
3
 
4
4
  declare const ExampleButton: React.FC<ChopLogicButtonProps>;
5
5
  export default ExampleButton;
@@ -0,0 +1,12 @@
1
+ import { MouseEventHandler } from 'react';
2
+ import { ChopLogicIconName } from '../../../../../../../../../src/components/misc/icon/Icon';
3
+
4
+ export type ChopLogicButtonView = 'primary' | 'secondary' | 'danger' | 'icon';
5
+ export type ChopLogicButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {
6
+ onClick?: MouseEventHandler<HTMLButtonElement> | (() => void);
7
+ view?: ChopLogicButtonView;
8
+ label?: string;
9
+ icon?: ChopLogicIconName;
10
+ text?: string;
11
+ extended?: boolean;
12
+ };
@@ -1,10 +1,5 @@
1
1
  import { default as React } from 'react';
2
+ import { ChopLogicCheckboxProps } from './types';
2
3
 
3
- export type ChopLogicCheckboxProps = React.InputHTMLAttributes<HTMLInputElement> & {
4
- name: string;
5
- label: string;
6
- noLabel?: boolean;
7
- iconPosition?: 'left' | 'right';
8
- };
9
4
  declare const ChopLogicCheckbox: React.FC<ChopLogicCheckboxProps>;
10
5
  export default ChopLogicCheckbox;
@@ -1,5 +1,5 @@
1
1
  import { default as React } from 'react';
2
- import { ChopLogicCheckboxProps } from '../Checkbox';
2
+ import { ChopLogicCheckboxProps } from '../types';
3
3
 
4
4
  declare const Example: React.FC<ChopLogicCheckboxProps>;
5
5
  export default Example;
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ export declare function useChopLogicCheckboxController({ name, defaultChecked, onChange, }: {
3
+ name: string;
4
+ defaultChecked?: boolean;
5
+ onChange?: React.ChangeEventHandler<HTMLInputElement>;
6
+ }): {
7
+ handleChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
8
+ checked: boolean;
9
+ };
@@ -1,9 +1,7 @@
1
- /// <reference types="react" />
2
- export declare function useChopLogicCheckboxController({ name, defaultChecked, onChange, }: {
3
- name: string;
1
+ import { ChopLogicFormData } from '../../../../../../../../../src/components/containers/form/types';
2
+
3
+ export declare function getCheckboxInitialValue({ defaultChecked, initialValues, name, }: {
4
4
  defaultChecked?: boolean;
5
- onChange?: React.ChangeEventHandler<HTMLInputElement>;
6
- }): {
7
- handleChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
8
- checked: boolean;
9
- };
5
+ initialValues?: ChopLogicFormData;
6
+ name: string;
7
+ }): boolean;
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ export type ChopLogicCheckboxProps = React.InputHTMLAttributes<HTMLInputElement> & {
3
+ name: string;
4
+ label: string;
5
+ noLabel?: boolean;
6
+ iconPosition?: 'left' | 'right';
7
+ };
@@ -1,21 +1,4 @@
1
- import { SelectValue } from '../select/Select';
1
+ import { ChopLogicMultiSelectProps } from './types';
2
2
 
3
- export type MultiSelectValue = SelectValue & {
4
- selected: boolean;
5
- };
6
- export type ChopLogicMultiSelectProps = React.SelectHTMLAttributes<HTMLSelectElement> & {
7
- name: string;
8
- label: string;
9
- options: SelectValue[];
10
- onChange?: (values?: SelectValue[]) => void;
11
- placeholder?: string;
12
- };
13
- export type MultiSelectDropdownProps = {
14
- options: MultiSelectValue[];
15
- opened: boolean;
16
- dropdownId: string;
17
- onClose: () => void;
18
- onSelect: (id: string) => void;
19
- };
20
3
  declare const ChopLogicMultiSelect: React.FC<ChopLogicMultiSelectProps>;
21
4
  export default ChopLogicMultiSelect;
@@ -1,5 +1,5 @@
1
1
  import { default as React } from 'react';
2
- import { ChopLogicMultiSelectProps } from '../MultiSelect';
2
+ import { ChopLogicMultiSelectProps } from '../types';
3
3
 
4
4
  declare const Example: React.FC<ChopLogicMultiSelectProps>;
5
5
  export default Example;
@@ -0,0 +1,15 @@
1
+ import { SelectValue } from '../select/types';
2
+ import { MultiSelectValue } from './types';
3
+
4
+ export declare function useChopLogicMultiSelectController({ name, defaultValue, onChange, options, }: {
5
+ name: string;
6
+ defaultValue?: string | number | readonly string[];
7
+ onChange?: (values?: SelectValue[]) => void;
8
+ options: SelectValue[];
9
+ }): {
10
+ handleClose: () => void;
11
+ handleToggle: () => void;
12
+ handleSelect: (id: string) => void;
13
+ opened: boolean;
14
+ values: MultiSelectValue[];
15
+ };
@@ -1,4 +1,4 @@
1
- import { MultiSelectValue } from '../MultiSelect';
1
+ import { MultiSelectValue } from '../types';
2
2
 
3
3
  type SelectComboboxProps = {
4
4
  opened: boolean;
@@ -1,4 +1,4 @@
1
- import { MultiSelectDropdownProps } from '../MultiSelect';
1
+ import { MultiSelectDropdownProps } from '../types';
2
2
 
3
3
  declare const MultiSelectDropdown: React.FC<MultiSelectDropdownProps>;
4
4
  export default MultiSelectDropdown;
@@ -1,4 +1,4 @@
1
- import { MultiSelectValue } from '../MultiSelect';
1
+ import { MultiSelectValue } from '../types';
2
2
 
3
3
  type SelectOptionProps = {
4
4
  value: MultiSelectValue;
@@ -1,6 +1,6 @@
1
- import { ChopLogicFormData } from '../../../../../../../../../src/components/containers/form/FormContext';
2
- import { SelectValue } from '../select/Select';
3
- import { MultiSelectValue } from './MultiSelect';
1
+ import { ChopLogicFormData } from '../../../../../../../../../src/components/containers/form/types';
2
+ import { SelectValue } from '../select/types';
3
+ import { MultiSelectValue } from './types';
4
4
 
5
5
  export declare function getMultiSelectInitialValues({ name, options, initialValues, defaultValue, }: {
6
6
  name: string;
@@ -8,15 +8,5 @@ export declare function getMultiSelectInitialValues({ name, options, initialValu
8
8
  initialValues?: ChopLogicFormData;
9
9
  defaultValue?: string | number | readonly string[];
10
10
  }): MultiSelectValue[];
11
- export declare function useChopLogicMultiSelectController({ name, defaultValue, onChange, options, }: {
12
- name: string;
13
- defaultValue?: string | number | readonly string[];
14
- onChange?: (values?: SelectValue[]) => void;
15
- options: SelectValue[];
16
- }): {
17
- handleClose: () => void;
18
- handleToggle: () => void;
19
- handleSelect: (id: string) => void;
20
- opened: boolean;
21
- values: MultiSelectValue[];
22
- };
11
+ export declare const getMultiSelectFormValues: (options: MultiSelectValue[]) => string[];
12
+ export declare const getMultiSelectUpdatedValues: (options: MultiSelectValue[], id: string) => MultiSelectValue[];
@@ -0,0 +1,19 @@
1
+ import { SelectValue } from '../select/types';
2
+
3
+ export type MultiSelectValue = SelectValue & {
4
+ selected: boolean;
5
+ };
6
+ export type ChopLogicMultiSelectProps = React.SelectHTMLAttributes<HTMLSelectElement> & {
7
+ name: string;
8
+ label: string;
9
+ options: SelectValue[];
10
+ onChange?: (values?: SelectValue[]) => void;
11
+ placeholder?: string;
12
+ };
13
+ export type MultiSelectDropdownProps = {
14
+ options: MultiSelectValue[];
15
+ opened: boolean;
16
+ dropdownId: string;
17
+ onClose: () => void;
18
+ onSelect: (id: string) => void;
19
+ };
@@ -1,14 +1,5 @@
1
1
  import { default as React } from 'react';
2
+ import { ChopLogicNumericInputProps } from './types';
2
3
 
3
- export type NumericValidationFunction = (input?: number) => boolean;
4
- export type ChopLogicNumericInputProps = React.InputHTMLAttributes<HTMLInputElement> & {
5
- name: string;
6
- label: string;
7
- errorMessage?: string;
8
- validator?: NumericValidationFunction;
9
- onClear?: () => void;
10
- hasSpinButtons?: boolean;
11
- onSpinButtonClick?: (value?: number) => void;
12
- };
13
4
  declare const ChopLogicNumericInput: React.FC<ChopLogicNumericInputProps>;
14
5
  export default ChopLogicNumericInput;
@@ -1,5 +1,5 @@
1
1
  import { default as React } from 'react';
2
- import { ChopLogicNumericInputProps } from '../NumericInput';
2
+ import { ChopLogicNumericInputProps } from '../types';
3
3
 
4
4
  declare const Example: React.FC<ChopLogicNumericInputProps>;
5
5
  export default Example;
@@ -0,0 +1,22 @@
1
+ import { ChangeEventHandler } from 'react';
2
+ import { NumericValidationFunction } from './types';
3
+
4
+ export declare function useChopLogicNumericInputController({ name, defaultValue, onChange, onSpinButtonClick, min, max, step, required, validator, }: {
5
+ name: string;
6
+ defaultValue?: string | number | readonly string[];
7
+ onChange?: ChangeEventHandler<HTMLInputElement>;
8
+ onSpinButtonClick?: (value?: number) => void;
9
+ min?: string | number;
10
+ max?: string | number;
11
+ step: number;
12
+ required: boolean;
13
+ validator?: NumericValidationFunction;
14
+ }): {
15
+ handleChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
16
+ value: number;
17
+ valid: boolean;
18
+ minValue: number;
19
+ maxValue: number;
20
+ increment: () => void;
21
+ decrement: () => void;
22
+ };
@@ -1,6 +1,5 @@
1
- import { ChangeEventHandler } from 'react';
2
- import { ChopLogicFormData } from '../../../../../../../../../src/components/containers/form/FormContext';
3
- import { NumericValidationFunction } from './NumericInput';
1
+ import { ChopLogicFormData } from '../../../../../../../../../src/components/containers/form/types';
2
+ import { NumericValidationFunction } from './types';
4
3
 
5
4
  export declare function getNumericInputInitialValue({ name, initialValues, defaultValue, }: {
6
5
  name: string;
@@ -14,22 +13,3 @@ export declare function validateNumericInputValue({ value, required, validator,
14
13
  maxValue?: number;
15
14
  minValue?: number;
16
15
  }): boolean;
17
- export declare function useChopLogicNumericInputController({ name, defaultValue, onChange, onSpinButtonClick, min, max, step, required, validator, }: {
18
- name: string;
19
- defaultValue?: string | number | readonly string[];
20
- onChange?: ChangeEventHandler<HTMLInputElement>;
21
- onSpinButtonClick?: (value?: number) => void;
22
- min?: string | number;
23
- max?: string | number;
24
- step: number;
25
- required: boolean;
26
- validator?: NumericValidationFunction;
27
- }): {
28
- handleChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
29
- value: number;
30
- valid: boolean;
31
- minValue: number;
32
- maxValue: number;
33
- increment: () => void;
34
- decrement: () => void;
35
- };
@@ -0,0 +1,11 @@
1
+ /// <reference types="react" />
2
+ export type NumericValidationFunction = (input?: number) => boolean;
3
+ export type ChopLogicNumericInputProps = React.InputHTMLAttributes<HTMLInputElement> & {
4
+ name: string;
5
+ label: string;
6
+ errorMessage?: string;
7
+ validator?: NumericValidationFunction;
8
+ onClear?: () => void;
9
+ hasSpinButtons?: boolean;
10
+ onSpinButtonClick?: (value?: number) => void;
11
+ };
@@ -1,16 +1,4 @@
1
- /// <reference types="react" />
2
- export type ChopLogicSelectProps = React.SelectHTMLAttributes<HTMLSelectElement> & {
3
- name: string;
4
- label: string;
5
- options: SelectValue[];
6
- onChange?: (value?: SelectValue) => void;
7
- placeholder?: string;
8
- };
9
- export type SelectValue = {
10
- id: string;
11
- label: string;
12
- } & {
13
- [key in string]: unknown;
14
- };
1
+ import { ChopLogicSelectProps } from './types';
2
+
15
3
  declare const ChopLogicSelect: React.FC<ChopLogicSelectProps>;
16
4
  export default ChopLogicSelect;
@@ -1,5 +1,5 @@
1
1
  import { default as React } from 'react';
2
- import { ChopLogicSelectProps } from '../Select';
2
+ import { ChopLogicSelectProps } from '../types';
3
3
 
4
4
  declare const Example: React.FC<ChopLogicSelectProps>;
5
5
  export default Example;
@@ -0,0 +1,15 @@
1
+ import { SelectValue } from './types';
2
+
3
+ export declare function useChopLogicSelectController({ name, defaultValue, onChange, options, }: {
4
+ name: string;
5
+ defaultValue?: string | number | readonly string[];
6
+ onChange?: (value?: SelectValue) => void;
7
+ options: SelectValue[];
8
+ }): {
9
+ selected: SelectValue | undefined;
10
+ opened: boolean;
11
+ handleClear: () => void;
12
+ handleClose: () => void;
13
+ handleToggle: () => void;
14
+ handleSelect: (id: string) => void;
15
+ };
@@ -1,4 +1,4 @@
1
- import { SelectValue } from '../Select';
1
+ import { SelectValue } from '../types';
2
2
 
3
3
  type SelectComboboxProps = {
4
4
  opened: boolean;
@@ -1,4 +1,4 @@
1
- import { SelectValue } from '../Select';
1
+ import { SelectValue } from '../types';
2
2
 
3
3
  type SelectDropdownProps = {
4
4
  options: SelectValue[];
@@ -1,10 +1,4 @@
1
- import { SelectValue } from '../Select';
1
+ import { SelectOptionProps } from '../types';
2
2
 
3
- type SelectOptionProps = {
4
- value: SelectValue;
5
- isSelected: boolean;
6
- onSelect: (id: string) => void;
7
- onClear: () => void;
8
- };
9
3
  declare const SelectOption: React.FC<SelectOptionProps>;
10
4
  export default SelectOption;