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.
- package/README.md +49 -1
- package/dist/components/containers/form/Form.d.ts +2 -8
- package/dist/components/containers/form/FormContext.d.ts +1 -15
- package/dist/components/containers/form/__docs__/FormExample.d.ts +1 -1
- package/dist/components/containers/form/controller.d.ts +1 -1
- package/dist/components/containers/form/helpers.d.ts +1 -1
- package/dist/components/containers/form/types.d.ts +23 -0
- package/dist/components/containers/grid/controller.d.ts +16 -0
- package/dist/components/containers/grid/elements/Checkbox.d.ts +2 -2
- package/dist/components/containers/tabs/Tabs.d.ts +1 -12
- package/dist/components/containers/tabs/Tabs.styled.d.ts +1 -1
- package/dist/components/containers/tabs/elements/TabButton.d.ts +1 -1
- package/dist/components/containers/tabs/elements/TabContent.d.ts +3 -4
- package/dist/components/containers/tabs/elements/TabList.d.ts +1 -1
- package/dist/components/containers/tabs/types.d.ts +13 -0
- package/dist/components/inputs/_common/input-inner-button/InputInnerButton.d.ts +2 -2
- package/dist/components/inputs/button/Button.d.ts +2 -11
- package/dist/components/inputs/button/Button.styled.d.ts +1 -1
- package/dist/components/inputs/button/__docs__/ButtonExample.d.ts +1 -1
- package/dist/components/inputs/button/types.d.ts +12 -0
- package/dist/components/inputs/checkbox/Checkbox.d.ts +1 -6
- package/dist/components/inputs/checkbox/__docs__/CheckboxExample.d.ts +1 -1
- package/dist/components/inputs/checkbox/controller.d.ts +9 -0
- package/dist/components/inputs/checkbox/helpers.d.ts +6 -8
- package/dist/components/inputs/checkbox/types.d.ts +7 -0
- package/dist/components/inputs/multi-select/MultiSelect.d.ts +1 -18
- package/dist/components/inputs/multi-select/__docs__/MultiSelectExample.d.ts +1 -1
- package/dist/components/inputs/multi-select/controller.d.ts +15 -0
- package/dist/components/inputs/multi-select/elements/Combobox.d.ts +1 -1
- package/dist/components/inputs/multi-select/elements/Dropdown.d.ts +1 -1
- package/dist/components/inputs/multi-select/elements/Option.d.ts +1 -1
- package/dist/components/inputs/multi-select/helpers.d.ts +5 -15
- package/dist/components/inputs/multi-select/types.d.ts +19 -0
- package/dist/components/inputs/numeric/NumericInput.d.ts +1 -10
- package/dist/components/inputs/numeric/__docs__/NumericInputExample.d.ts +1 -1
- package/dist/components/inputs/numeric/controller.d.ts +22 -0
- package/dist/components/inputs/numeric/helpers.d.ts +2 -22
- package/dist/components/inputs/numeric/types.d.ts +11 -0
- package/dist/components/inputs/select/Select.d.ts +2 -14
- package/dist/components/inputs/select/__docs__/SelectExample.d.ts +1 -1
- package/dist/components/inputs/select/controller.d.ts +15 -0
- package/dist/components/inputs/select/elements/Combobox.d.ts +1 -1
- package/dist/components/inputs/select/elements/Dropdown.d.ts +1 -1
- package/dist/components/inputs/select/elements/Option.d.ts +1 -7
- package/dist/components/inputs/select/helpers.d.ts +2 -15
- package/dist/components/inputs/select/types.d.ts +20 -0
- package/dist/components/inputs/text/TextInput.d.ts +1 -15
- package/dist/components/inputs/text/__docs__/TextInputExample.d.ts +1 -1
- package/dist/components/inputs/text/controller.d.ts +18 -0
- package/dist/components/inputs/text/helpers.d.ts +2 -18
- package/dist/components/inputs/text/types.d.ts +15 -0
- package/dist/components/misc/icon/Icon.d.ts +2 -2
- package/dist/components/modals/alert/Alert.d.ts +1 -10
- package/dist/components/modals/alert/__docs__/Alert.stories.d.ts +1 -1
- package/dist/components/modals/alert/elements/Header.d.ts +1 -8
- package/dist/components/modals/alert/helpers.d.ts +5 -0
- package/dist/components/modals/alert/types.d.ts +17 -0
- package/dist/components/modals/dialog/Dialog.d.ts +2 -7
- package/dist/components/modals/dialog/__docs__/DialogExample.d.ts +2 -2
- package/dist/components/modals/dialog/elements/Header.d.ts +2 -3
- package/dist/components/modals/dialog/elements/Layout.d.ts +3 -7
- package/dist/components/modals/dialog/types.d.ts +12 -0
- package/dist/components/modals/tooltip/Tooltip.d.ts +1 -6
- package/dist/components/modals/tooltip/__docs__/TooltipExample.d.ts +1 -1
- package/dist/components/modals/tooltip/controller.d.ts +15 -0
- package/dist/components/modals/tooltip/types.d.ts +8 -0
- package/dist/constants/style-variables.d.ts +3 -3
- package/dist/index.cjs.js +91 -91
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +2830 -3357
- package/dist/index.es.js.map +1 -1
- package/package.json +2 -2
- package/dist/components/modals/alert/helpers/get-alert-title.d.ts +0 -3
- package/dist/components/modals/alert/helpers/render-alert-icon.d.ts +0 -4
- package/dist/utils/__tests__/create-class-name.test.d.ts +0 -1
- 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
|
-
|
|
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
|
|
2
|
-
import {
|
|
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,5 +1,5 @@
|
|
|
1
1
|
import { FormEvent } from 'react';
|
|
2
|
-
import { ChopLogicFormData, ChopLogicFormInputParams } from './
|
|
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 './
|
|
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
|
-
|
|
3
|
+
type ChopLogicGridCheckboxProps = React.InputHTMLAttributes<HTMLInputElement> & {
|
|
4
4
|
label: string;
|
|
5
5
|
};
|
|
6
|
-
declare const GridCheckbox: React.FC<
|
|
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 './
|
|
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,9 +1,8 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
import { ChopLogicTabItem } from '../
|
|
2
|
+
import { ChopLogicTabItem } from '../types';
|
|
3
3
|
|
|
4
|
-
|
|
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;
|
|
@@ -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 {
|
|
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:
|
|
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
|
|
2
|
-
import {
|
|
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 './
|
|
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;
|
|
@@ -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;
|
|
@@ -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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { ChopLogicFormData } from '../../../../../../../../../src/components/containers/form/types';
|
|
2
|
+
|
|
3
|
+
export declare function getCheckboxInitialValue({ defaultChecked, initialValues, name, }: {
|
|
4
4
|
defaultChecked?: boolean;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
checked: boolean;
|
|
9
|
-
};
|
|
5
|
+
initialValues?: ChopLogicFormData;
|
|
6
|
+
name: string;
|
|
7
|
+
}): boolean;
|
|
@@ -1,21 +1,4 @@
|
|
|
1
|
-
import {
|
|
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;
|
|
@@ -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,6 +1,6 @@
|
|
|
1
|
-
import { ChopLogicFormData } from '../../../../../../../../../src/components/containers/form/
|
|
2
|
-
import { SelectValue } from '../select/
|
|
3
|
-
import { MultiSelectValue } from './
|
|
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
|
|
12
|
-
|
|
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;
|
|
@@ -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 {
|
|
2
|
-
import {
|
|
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
|
-
|
|
2
|
-
|
|
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;
|
|
@@ -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,10 +1,4 @@
|
|
|
1
|
-
import {
|
|
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;
|