@bodynarf/react.components 1.0.2 → 1.1.4
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/{src/components → components}/anchor/anchor.scss +0 -0
- package/components/anchor/components/anchorWithIcon/index.d.ts +5 -0
- package/components/anchor/components/anchorWithIcon/index.d.ts.map +1 -0
- package/components/anchor/components/anchorWithIcon/index.js +16 -0
- package/components/anchor/components/simpleAnchor/index.d.ts +5 -0
- package/components/anchor/components/simpleAnchor/index.d.ts.map +1 -0
- package/components/anchor/components/simpleAnchor/index.js +5 -0
- package/components/anchor/index.d.ts +24 -0
- package/components/anchor/index.d.ts.map +1 -0
- package/components/anchor/index.js +18 -0
- package/{src/components/anchor/types.ts → components/anchor/types.d.ts} +3 -9
- package/components/anchor/types.d.ts.map +1 -0
- package/components/anchor/types.js +1 -0
- package/{src/components → components}/button/button.scss +0 -0
- package/components/button/components/buttonWithIcon/index.d.ts +5 -0
- package/components/button/components/buttonWithIcon/index.d.ts.map +1 -0
- package/components/button/components/buttonWithIcon/index.js +19 -0
- package/components/button/components/simpleButton/index.d.ts +5 -0
- package/components/button/components/simpleButton/index.d.ts.map +1 -0
- package/components/button/components/simpleButton/index.js +5 -0
- package/components/button/index.d.ts +34 -0
- package/components/button/index.d.ts.map +1 -0
- package/components/button/index.js +27 -0
- package/components/button/types.d.ts +20 -0
- package/components/button/types.d.ts.map +1 -0
- package/components/button/types.js +1 -0
- package/components/dropdown/components/dropdownItem/index.d.ts +15 -0
- package/components/dropdown/components/dropdownItem/index.d.ts.map +1 -0
- package/components/dropdown/components/dropdownItem/index.js +6 -0
- package/components/dropdown/components/dropdownLabel/index.d.ts +16 -0
- package/components/dropdown/components/dropdownLabel/index.d.ts.map +1 -0
- package/components/dropdown/components/dropdownLabel/index.js +21 -0
- package/{src/components → components}/dropdown/dropdown.scss +0 -0
- package/components/dropdown/index.d.ts +31 -0
- package/components/dropdown/index.d.ts.map +1 -0
- package/components/dropdown/index.js +57 -0
- package/{src/components/dropdown/types.ts → components/dropdown/types.d.ts} +3 -4
- package/components/dropdown/types.d.ts.map +1 -0
- package/components/dropdown/types.js +1 -0
- package/{src/components → components}/icon/icon.scss +0 -0
- package/components/icon/index.d.ts +18 -0
- package/components/icon/index.d.ts.map +1 -0
- package/components/icon/index.js +15 -0
- package/components/primitives/date/index.d.ts +11 -0
- package/components/primitives/date/index.d.ts.map +1 -0
- package/components/primitives/date/index.js +31 -0
- package/components/primitives/index.d.ts +5 -0
- package/components/primitives/index.d.ts.map +1 -0
- package/components/primitives/index.js +4 -0
- package/components/primitives/multiline/components/multilineWithLabel/index.d.ts +6 -0
- package/components/primitives/multiline/components/multilineWithLabel/index.d.ts.map +1 -0
- package/components/primitives/multiline/components/multilineWithLabel/index.js +29 -0
- package/components/primitives/multiline/components/multilineWithoutLabel/index.d.ts +6 -0
- package/components/primitives/multiline/components/multilineWithoutLabel/index.d.ts.map +1 -0
- package/components/primitives/multiline/components/multilineWithoutLabel/index.js +25 -0
- package/components/primitives/multiline/index.d.ts +13 -0
- package/components/primitives/multiline/index.d.ts.map +1 -0
- package/components/primitives/multiline/index.js +14 -0
- package/components/primitives/text/components/textWithLabel/index.d.ts +6 -0
- package/components/primitives/text/components/textWithLabel/index.d.ts.map +1 -0
- package/components/primitives/text/components/textWithLabel/index.js +28 -0
- package/components/primitives/text/components/textWithoutLabel/index.d.ts +6 -0
- package/components/primitives/text/components/textWithoutLabel/index.d.ts.map +1 -0
- package/components/primitives/text/components/textWithoutLabel/index.js +24 -0
- package/components/primitives/text/index.d.ts +8 -0
- package/components/primitives/text/index.d.ts.map +1 -0
- package/components/primitives/text/index.js +14 -0
- package/{src/components/primitives/types.ts → components/primitives/types.d.ts} +5 -32
- package/components/primitives/types.d.ts.map +1 -0
- package/components/primitives/types.js +1 -0
- package/components/search/index.d.ts +31 -0
- package/components/search/index.d.ts.map +1 -0
- package/components/search/index.js +39 -0
- package/{src/components → components}/search/search.scss +0 -0
- package/{src/components/types.ts → components/types.d.ts} +5 -16
- package/components/types.d.ts.map +1 -0
- package/components/types.js +1 -0
- package/hooks/index.d.ts +2 -0
- package/hooks/index.d.ts.map +1 -0
- package/hooks/index.js +1 -0
- package/hooks/useComponentOutsideClick.d.ts +11 -0
- package/hooks/useComponentOutsideClick.d.ts.map +1 -0
- package/hooks/useComponentOutsideClick.js +32 -0
- package/index.d.ts +10 -0
- package/index.d.ts.map +1 -0
- package/index.js +9 -0
- package/package.json +9 -19
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -25
- package/index.html +0 -13
- package/src/components/anchor/components/anchorWithIcon/anchorWithIcon.tsx +0 -45
- package/src/components/anchor/components/simpleAnchor/simpleAnchor.tsx +0 -16
- package/src/components/anchor/index.tsx +0 -64
- package/src/components/button/components/buttonWithIcon/buttonWithIcon.tsx +0 -47
- package/src/components/button/components/simpleButton/simpleButton.tsx +0 -16
- package/src/components/button/index.tsx +0 -83
- package/src/components/button/types.ts +0 -40
- package/src/components/dropdown/components/dropdownItem/dropdownItem.tsx +0 -30
- package/src/components/dropdown/components/dropdownLabel/dropdownLabel.tsx +0 -60
- package/src/components/dropdown/index.tsx +0 -141
- package/src/components/icon/index.tsx +0 -34
- package/src/components/primitives/date/index.tsx +0 -103
- package/src/components/primitives/multiline/components/multilineWithLabel/index.tsx +0 -93
- package/src/components/primitives/multiline/components/multilineWithoutLabel/index.tsx +0 -51
- package/src/components/primitives/multiline/index.tsx +0 -28
- package/src/components/primitives/text/components/textWithLabel/index.tsx +0 -92
- package/src/components/primitives/text/components/textWithoutLabel/index.tsx +0 -49
- package/src/components/primitives/text/index.tsx +0 -21
- package/src/components/search/index.tsx +0 -127
- package/src/hooks/useComponentOutsideClick.ts +0 -48
- package/src/main.tsx +0 -9
- package/tsconfig.json +0 -48
- package/tsconfig.node.json +0 -8
- package/vite.config.ts +0 -14
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
import utils from '@bodynarf/utils';
|
|
4
|
+
/** Multiline textual input component with describing label */
|
|
5
|
+
const MultilineWithLabel = (props) => {
|
|
6
|
+
const onValueChange = useCallback((event) => props.onValueChange(event.target.value),
|
|
7
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
8
|
+
[props.onValueChange]);
|
|
9
|
+
const id = props.name || utils.generateGuid();
|
|
10
|
+
const size = `is-${(props.size || 'normal')}`;
|
|
11
|
+
const className = utils.getClassName([
|
|
12
|
+
props.className,
|
|
13
|
+
size,
|
|
14
|
+
props.rounded === true ? 'is-rounded' : '',
|
|
15
|
+
"textarea",
|
|
16
|
+
props.fixed === true ? 'has-fixed-size' : '',
|
|
17
|
+
]);
|
|
18
|
+
const inputContainerClassName = utils.getClassName([
|
|
19
|
+
"control",
|
|
20
|
+
props.loading === true ? 'is-loading' : '',
|
|
21
|
+
(props.style || 'default') === 'default' ? '' : `is-${props.style}`
|
|
22
|
+
]);
|
|
23
|
+
const label = props.label;
|
|
24
|
+
if (label.horizontal === true) {
|
|
25
|
+
return (_jsxs("div", { className: "app-input field is-horizontal", children: [_jsx("div", { className: `field-label ${size}`, children: _jsx("label", { className: "label", htmlFor: id, children: label.caption }) }), _jsx("div", { className: "field-body", children: _jsx("div", { className: "field", children: _jsx("div", { className: inputContainerClassName, children: _jsx("textarea", { className: className, placeholder: props.placeholder, readOnly: props.readonly, disabled: props.disabled, defaultValue: props.defaultValue, onChange: onValueChange, name: id, id: id, rows: props.rows }) }) }) })] }));
|
|
26
|
+
}
|
|
27
|
+
return (_jsxs("div", { className: "app-input field", children: [_jsx("label", { className: `label ${size}`, htmlFor: id, children: label.caption }), _jsx("div", { className: inputContainerClassName, children: _jsx("textarea", { className: className, placeholder: props.placeholder, readOnly: props.readonly, disabled: props.disabled, defaultValue: props.defaultValue, onChange: onValueChange, name: id, id: id, rows: props.rows }) })] }));
|
|
28
|
+
};
|
|
29
|
+
export default MultilineWithLabel;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { MultilineProps } from '../..';
|
|
3
|
+
/** Multiline textual input component without describing label*/
|
|
4
|
+
declare const MultilineWithoutLabel: (props: MultilineProps) => JSX.Element;
|
|
5
|
+
export default MultilineWithoutLabel;
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/primitives/multiline/components/multilineWithoutLabel/index.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAEvC,gEAAgE;AAChE,QAAA,MAAM,qBAAqB,UAAW,cAAc,KAAG,WAwCtD,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
import utils from '@bodynarf/utils';
|
|
4
|
+
/** Multiline textual input component without describing label*/
|
|
5
|
+
const MultilineWithoutLabel = (props) => {
|
|
6
|
+
const onValueChange = useCallback((event) => props.onValueChange(event.target.value),
|
|
7
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
8
|
+
[props.onValueChange]);
|
|
9
|
+
const id = props.name || utils.generateGuid();
|
|
10
|
+
const size = `is-${(props.size || 'normal')}`;
|
|
11
|
+
const className = utils.getClassName([
|
|
12
|
+
props.className,
|
|
13
|
+
size,
|
|
14
|
+
props.rounded === true ? 'is-rounded' : '',
|
|
15
|
+
"textarea",
|
|
16
|
+
props.fixed === true ? 'has-fixed-size' : '',
|
|
17
|
+
]);
|
|
18
|
+
const inputContainerClassName = utils.getClassName([
|
|
19
|
+
"control",
|
|
20
|
+
props.loading === true ? 'is-loading' : '',
|
|
21
|
+
(props.style || 'default') === 'default' ? '' : `is-${props.style}`
|
|
22
|
+
]);
|
|
23
|
+
return (_jsx("div", { className: "field", children: _jsx("div", { className: inputContainerClassName, children: _jsx("textarea", { className: className, placeholder: props.placeholder, defaultValue: props.defaultValue, onChange: onValueChange, id: id, name: id, rows: props.rows }) }) }));
|
|
24
|
+
};
|
|
25
|
+
export default MultilineWithoutLabel;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { BaseInputElementProps } from '../types';
|
|
3
|
+
/** Multiline textual input conponent props type */
|
|
4
|
+
export declare type MultilineProps = BaseInputElementProps<string> & {
|
|
5
|
+
/** Is input should be resizable */
|
|
6
|
+
fixed?: boolean;
|
|
7
|
+
/** Number of initial rows count */
|
|
8
|
+
rows?: number;
|
|
9
|
+
};
|
|
10
|
+
/** Multiline textual input component */
|
|
11
|
+
declare const Multiline: (props: MultilineProps) => JSX.Element;
|
|
12
|
+
export default Multiline;
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/primitives/multiline/index.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAKjD,mDAAmD;AACnD,oBAAY,cAAc,GAAG,qBAAqB,CAAC,MAAM,CAAC,GAAG;IACzD,mCAAmC;IACnC,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB,mCAAmC;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,wCAAwC;AACxC,QAAA,MAAM,SAAS,UAAW,cAAc,KAAG,WAQ1C,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import utils from '@bodynarf/utils';
|
|
3
|
+
import MultilineWithoutLabel from './components/multilineWithoutLabel';
|
|
4
|
+
import MultilineWithLabel from './components/multilineWithLabel';
|
|
5
|
+
/** Multiline textual input component */
|
|
6
|
+
const Multiline = (props) => {
|
|
7
|
+
if (utils.isNullOrUndefined(props.label)) {
|
|
8
|
+
return (_jsx(MultilineWithoutLabel, { ...props }));
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
return (_jsx(MultilineWithLabel, { ...props }));
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
export default Multiline;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/primitives/text/components/textWithLabel/index.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,0CAA0C;AAC1C,QAAA,MAAM,aAAa,UAAW,SAAS,KAAG,WAiFzC,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
import utils from '@bodynarf/utils';
|
|
4
|
+
/** Textual input with describing label */
|
|
5
|
+
const TextWithLabel = (props) => {
|
|
6
|
+
const onValueChange = useCallback((event) => props.onValueChange(event.target.value),
|
|
7
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
8
|
+
[props.onValueChange]);
|
|
9
|
+
const id = props.name || utils.generateGuid();
|
|
10
|
+
const size = `is-${(props.size || 'normal')}`;
|
|
11
|
+
const className = utils.getClassName([
|
|
12
|
+
props.className,
|
|
13
|
+
size,
|
|
14
|
+
props.rounded === true ? 'is-rounded' : '',
|
|
15
|
+
"input",
|
|
16
|
+
]);
|
|
17
|
+
const inputContainerClassName = utils.getClassName([
|
|
18
|
+
"control",
|
|
19
|
+
props.loading === true ? 'is-loading' : '',
|
|
20
|
+
(props.style || 'default') === 'default' ? '' : `is-${props.style}`
|
|
21
|
+
]);
|
|
22
|
+
const label = props.label;
|
|
23
|
+
if (label.horizontal === true) {
|
|
24
|
+
return (_jsxs("div", { className: "app-input field is-horizontal", children: [_jsx("div", { className: `field-label ${size}`, children: _jsx("label", { className: "label", htmlFor: id, children: label.caption }) }), _jsx("div", { className: "field-body", children: _jsx("div", { className: "field", children: _jsx("div", { className: inputContainerClassName, children: _jsx("input", { className: className, type: "text", placeholder: props.placeholder, readOnly: props.readonly, disabled: props.disabled, defaultValue: props.defaultValue, onChange: onValueChange, name: id, id: id }) }) }) })] }));
|
|
25
|
+
}
|
|
26
|
+
return (_jsxs("div", { className: "app-input field", children: [_jsx("label", { className: `label ${size}`, htmlFor: id, children: label.caption }), _jsx("div", { className: inputContainerClassName, children: _jsx("input", { className: className, type: "text", placeholder: props.placeholder, readOnly: props.readonly, disabled: props.disabled, defaultValue: props.defaultValue, onChange: onValueChange, name: id, id: id }) })] }));
|
|
27
|
+
};
|
|
28
|
+
export default TextWithLabel;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/primitives/text/components/textWithoutLabel/index.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,6CAA6C;AAC7C,QAAA,MAAM,gBAAgB,UAAW,SAAS,KAAG,WAsC5C,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
import utils from '@bodynarf/utils';
|
|
4
|
+
/** Textual input without describing label */
|
|
5
|
+
const TextWithoutLabel = (props) => {
|
|
6
|
+
const onValueChange = useCallback((event) => props.onValueChange(event.target.value),
|
|
7
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
8
|
+
[props.onValueChange]);
|
|
9
|
+
const className = utils.getClassName([
|
|
10
|
+
props.className,
|
|
11
|
+
`is-${(props.size || 'normal')}`,
|
|
12
|
+
props.rounded === true ? 'is-rounded' : '',
|
|
13
|
+
"input",
|
|
14
|
+
]);
|
|
15
|
+
const containerClassName = utils.getClassName([
|
|
16
|
+
"app-input",
|
|
17
|
+
"control",
|
|
18
|
+
props.loading === true ? 'is-loading' : '',
|
|
19
|
+
(props.style || 'default') === 'default' ? '' : `is-${props.style}`
|
|
20
|
+
]);
|
|
21
|
+
const id = props.name || utils.generateGuid();
|
|
22
|
+
return (_jsx("div", { className: containerClassName, children: _jsx("input", { className: className, type: "text", placeholder: props.placeholder, readOnly: props.readonly, disabled: props.disabled, defaultValue: props.defaultValue, onChange: onValueChange, name: id, id: id }) }));
|
|
23
|
+
};
|
|
24
|
+
export default TextWithoutLabel;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { BaseInputElementProps } from '../types';
|
|
3
|
+
/** Text input conponent props type */
|
|
4
|
+
export declare type TextProps = BaseInputElementProps<string>;
|
|
5
|
+
/** Textual input component */
|
|
6
|
+
declare const Text: (props: TextProps) => JSX.Element;
|
|
7
|
+
export default Text;
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/primitives/text/index.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAKjD,sCAAsC;AACtC,oBAAY,SAAS,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC;AAEtD,8BAA8B;AAC9B,QAAA,MAAM,IAAI,UAAW,SAAS,KAAG,WAOhC,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import utils from '@bodynarf/utils';
|
|
3
|
+
import TextWithLabel from './components/textWithLabel';
|
|
4
|
+
import TextWithoutLabel from './components/textWithoutLabel';
|
|
5
|
+
/** Textual input component */
|
|
6
|
+
const Text = (props) => {
|
|
7
|
+
if (utils.isNullOrUndefined(props.label)) {
|
|
8
|
+
return (_jsx(TextWithoutLabel, { ...props }));
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
return (_jsx(TextWithLabel, { ...props }));
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
export default Text;
|
|
@@ -1,65 +1,38 @@
|
|
|
1
1
|
import { BaseElementProps } from "../types";
|
|
2
|
-
|
|
3
2
|
/** Base properties for input components */
|
|
4
|
-
export type BaseInputElementProps<TValue> = BaseElementProps & {
|
|
3
|
+
export declare type BaseInputElementProps<TValue> = BaseElementProps & {
|
|
5
4
|
/** Value change handler. Changed value must be stored outside of component */
|
|
6
5
|
onValueChange: (value: TValue) => void;
|
|
7
|
-
|
|
8
6
|
/** Default value of input component*/
|
|
9
7
|
defaultValue?: TValue;
|
|
10
|
-
|
|
11
8
|
/** Input element placeholder */
|
|
12
9
|
placeholder?: string;
|
|
13
|
-
|
|
14
10
|
/** Is component borders are rounded */
|
|
15
11
|
rounded?: boolean;
|
|
16
|
-
|
|
17
12
|
/** Should be component disabled. Selecting is not allowed */
|
|
18
13
|
disabled?: boolean;
|
|
19
|
-
|
|
20
14
|
/** Should be component int read only mode. Selecting is allowed */
|
|
21
15
|
readonly?: boolean;
|
|
22
|
-
|
|
23
16
|
/** Component size */
|
|
24
17
|
size?: InputSize;
|
|
25
|
-
|
|
26
18
|
/** Label configuration */
|
|
27
19
|
label?: InputLabel;
|
|
28
|
-
|
|
29
20
|
/** Displaying loading state of component as spinner in right end of component */
|
|
30
21
|
loading?: boolean;
|
|
31
|
-
|
|
32
22
|
/** Style. Colors the border */
|
|
33
23
|
style?: InputColor;
|
|
34
|
-
|
|
35
24
|
/** Name of element. Required for form elements */
|
|
36
25
|
name?: string;
|
|
37
26
|
};
|
|
38
|
-
|
|
39
27
|
/** Input label configuration */
|
|
40
|
-
export type InputLabel = {
|
|
28
|
+
export declare type InputLabel = {
|
|
41
29
|
/** Label textual content to describe input requirements */
|
|
42
30
|
caption: string;
|
|
43
|
-
|
|
44
31
|
/** Should component be on same line with label */
|
|
45
32
|
horizontal?: boolean;
|
|
46
33
|
};
|
|
47
|
-
|
|
48
34
|
/** Input component size variety */
|
|
49
|
-
export type InputSize =
|
|
50
|
-
| 'small'
|
|
51
|
-
| 'normal'
|
|
52
|
-
| 'medium'
|
|
53
|
-
| 'large'
|
|
54
|
-
;
|
|
55
|
-
|
|
35
|
+
export declare type InputSize = 'small' | 'normal' | 'medium' | 'large';
|
|
56
36
|
/** Input component border-color type */
|
|
57
|
-
export type InputColor =
|
|
58
|
-
|
|
59
|
-
| 'primary' /** color: seawave green */
|
|
60
|
-
| 'link' /** color: blue-violet */
|
|
61
|
-
| 'info' /** color: sky-blue */
|
|
62
|
-
| 'success' /** color: green */
|
|
63
|
-
| 'warning' /** color: yellow */
|
|
64
|
-
| 'danger' /** color: red */
|
|
65
|
-
;
|
|
37
|
+
export declare type InputColor = 'default' /** color: transparent */ | 'primary' /** color: seawave green */ | 'link' /** color: blue-violet */ | 'info' /** color: sky-blue */ | 'success' /** color: green */ | 'warning' /** color: yellow */ | 'danger' /** color: red */;
|
|
38
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/primitives/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE5C,2CAA2C;AAC3C,oBAAY,qBAAqB,CAAC,MAAM,IAAI,gBAAgB,GAAG;IAC3D,8EAA8E;IAC9E,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAEvC,sCAAsC;IACtC,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,gCAAgC;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,uCAAuC;IACvC,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,mEAAmE;IACnE,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,qBAAqB;IACrB,IAAI,CAAC,EAAE,SAAS,CAAC;IAEjB,0BAA0B;IAC1B,KAAK,CAAC,EAAE,UAAU,CAAC;IAEnB,iFAAiF;IACjF,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,+BAA+B;IAC/B,KAAK,CAAC,EAAE,UAAU,CAAC;IAEnB,kDAAkD;IAClD,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,gCAAgC;AAChC,oBAAY,UAAU,GAAG;IACrB,2DAA2D;IAC3D,OAAO,EAAE,MAAM,CAAC;IAEhB,kDAAkD;IAClD,UAAU,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,mCAAmC;AACnC,oBAAY,SAAS,GACf,OAAO,GACP,QAAQ,GACR,QAAQ,GACR,OAAO,CACR;AAEL,wCAAwC;AACxC,oBAAY,UAAU,GAChB,SAAS,CAAC,yBAAyB,GACnC,SAAS,CAAC,2BAA2B,GACrC,MAAM,CAAC,yBAAyB,GAChC,MAAM,CAAC,sBAAsB,GAC7B,SAAS,CAAC,mBAAmB,GAC7B,SAAS,CAAC,oBAAoB,GAC9B,QAAQ,CAAC,iBAAiB,CAC3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import './search.scss';
|
|
3
|
+
export declare type SearchProps = {
|
|
4
|
+
/** Search caption */
|
|
5
|
+
caption: string;
|
|
6
|
+
/** Search handler */
|
|
7
|
+
onSearch: (searchPattern: string) => void;
|
|
8
|
+
/** Initial search value */
|
|
9
|
+
defaultValue?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Search type: by typing, starts from minimum characters to search
|
|
12
|
+
* or by clicking on button next to search bar.
|
|
13
|
+
* Default is byTyping
|
|
14
|
+
*/
|
|
15
|
+
searchType?: 'byTyping' | 'byButton';
|
|
16
|
+
/** Control name. If empty - will be replaced by random guid */
|
|
17
|
+
name?: string;
|
|
18
|
+
/** Minimum amount of characters to search */
|
|
19
|
+
minCharsToSearch?: number;
|
|
20
|
+
/** Size of search bar */
|
|
21
|
+
size?: 'small' | 'normal' | 'medium' | 'large';
|
|
22
|
+
/** Should search bar be rounded */
|
|
23
|
+
rounded?: boolean;
|
|
24
|
+
/** Is search bar disabled */
|
|
25
|
+
disabled?: boolean;
|
|
26
|
+
/** Should loading icon be displayed in search bar*/
|
|
27
|
+
isLoading?: boolean;
|
|
28
|
+
};
|
|
29
|
+
/** Search component */
|
|
30
|
+
export default function Search(props: SearchProps): JSX.Element;
|
|
31
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/search/index.tsx"],"names":[],"mappings":";AAIA,OAAO,eAAe,CAAC;AAIvB,oBAAY,WAAW,GAAG;IACtB,qBAAqB;IACrB,OAAO,EAAE,MAAM,CAAC;IAEhB,qBAAqB;IACrB,QAAQ,EAAE,CAAC,aAAa,EAAE,MAAM,KAAK,IAAI,CAAC;IAE1C,2BAA2B;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;;MAIE;IACF,UAAU,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC;IAErC,+DAA+D;IAC/D,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,6CAA6C;IAC7C,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B,yBAAyB;IACzB,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC;IAE/C,mCAAmC;IACnC,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,6BAA6B;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,oDAAoD;IACpD,SAAS,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,uBAAuB;AACvB,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,GAAG,CAAC,OAAO,CAgF9D"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useState } from 'react';
|
|
3
|
+
import utils from '@bodynarf/utils';
|
|
4
|
+
import './search.scss';
|
|
5
|
+
import Button from '../button';
|
|
6
|
+
/** Search component */
|
|
7
|
+
export default function Search(props) {
|
|
8
|
+
const [name] = useState(props.name || utils.generateGuid());
|
|
9
|
+
const [searchValue, setSearchValue] = useState(props.defaultValue || '');
|
|
10
|
+
const searchType = props.searchType || 'byTyping';
|
|
11
|
+
const onChange = useCallback((event) => {
|
|
12
|
+
const elementValue = event.target.value;
|
|
13
|
+
if (searchType === 'byTyping') {
|
|
14
|
+
const minCharsToSearch = utils.isNullOrUndefined(props.minCharsToSearch)
|
|
15
|
+
? 3
|
|
16
|
+
: props.minCharsToSearch;
|
|
17
|
+
if (elementValue.length >= minCharsToSearch) {
|
|
18
|
+
props.onSearch(elementValue);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
setSearchValue(elementValue);
|
|
22
|
+
}, [props, searchType]);
|
|
23
|
+
const onSearchButtonClick = useCallback(() => {
|
|
24
|
+
props.onSearch(searchValue);
|
|
25
|
+
}, [props, searchValue]);
|
|
26
|
+
const className = 'app-search control'
|
|
27
|
+
+ ` is-${(props.size || 'normal')}`
|
|
28
|
+
+ (props.isLoading === true ? ' is-loading' : '')
|
|
29
|
+
+ (searchType === 'byButton' ? ' is-expanded' : '');
|
|
30
|
+
const inputClassName = 'input is-unselectable'
|
|
31
|
+
+ ` is-${(props.size || 'normal')}`
|
|
32
|
+
+ (props.rounded === true ? ' is-rounded' : '');
|
|
33
|
+
if (searchType === 'byButton') {
|
|
34
|
+
return (_jsxs("div", { className: "field has-addons", children: [_jsx("div", { className: className, children: _jsx("input", { type: 'search', name: name, defaultValue: searchValue, className: inputClassName, disabled: props.disabled, onChange: onChange, placeholder: props.caption }) }), _jsx("div", { className: "control", children: _jsx(Button, { caption: "Search", type: "info", onClick: onSearchButtonClick, isLoading: props.isLoading }) })] }));
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
return (_jsx("div", { className: className, children: _jsx("input", { type: 'search', name: name, defaultValue: searchValue, className: inputClassName, disabled: props.disabled, onChange: onChange, placeholder: props.caption }) }));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
File without changes
|
|
@@ -1,41 +1,30 @@
|
|
|
1
1
|
/** Base interface for component props */
|
|
2
|
-
export type BaseElementProps = {
|
|
2
|
+
export declare type BaseElementProps = {
|
|
3
3
|
/** Additional class names */
|
|
4
4
|
className?: string;
|
|
5
|
-
|
|
6
5
|
/** Title */
|
|
7
6
|
title?: string;
|
|
8
|
-
|
|
9
7
|
/** Extra data-* attributes */
|
|
10
8
|
data?: {
|
|
11
9
|
/**Will add data-{key} attribute to element */
|
|
12
10
|
[key: string]: any;
|
|
13
11
|
};
|
|
14
12
|
};
|
|
15
|
-
|
|
16
|
-
export type
|
|
17
|
-
| 'small'
|
|
18
|
-
| 'medium' /** default size */
|
|
19
|
-
| 'large';
|
|
20
|
-
|
|
21
|
-
export type IconPosition =
|
|
22
|
-
| 'left'
|
|
23
|
-
| 'right';
|
|
24
|
-
|
|
13
|
+
export declare type IconSize = 'small' | 'medium' /** default size */ | 'large';
|
|
14
|
+
export declare type IconPosition = 'left' | 'right';
|
|
25
15
|
/** Icon for component configuration */
|
|
26
|
-
export type ElementIcon = {
|
|
16
|
+
export declare type ElementIcon = {
|
|
27
17
|
/**
|
|
28
18
|
* Class name for icon.
|
|
29
19
|
* Used to display icon from bootstrap-icons
|
|
30
20
|
*/
|
|
31
21
|
className: string;
|
|
32
|
-
|
|
33
22
|
/** Icon size */
|
|
34
23
|
size?: IconSize;
|
|
35
|
-
|
|
36
24
|
/**
|
|
37
25
|
* Position
|
|
38
26
|
* Works only with other content
|
|
39
27
|
*/
|
|
40
28
|
position?: IconPosition;
|
|
41
29
|
};
|
|
30
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/components/types.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,oBAAY,gBAAgB,GAAG;IAC3B,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,YAAY;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,8BAA8B;IAC9B,IAAI,CAAC,EAAE;QACH,8CAA8C;QAC9C,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACtB,CAAC;CACL,CAAC;AAEF,oBAAY,QAAQ,GACd,OAAO,GACP,QAAQ,CAAC,mBAAmB,GAC5B,OAAO,CAAC;AAEd,oBAAY,YAAY,GAClB,MAAM,GACN,OAAO,CAAC;AAEd,uCAAuC;AACvC,oBAAY,WAAW,GAAG;IACtB;;;MAGE;IACF,SAAS,EAAE,MAAM,CAAC;IAElB,gBAAgB;IAChB,IAAI,CAAC,EAAE,QAAQ,CAAC;IAEhB;;;MAGE;IACF,QAAQ,CAAC,EAAE,YAAY,CAAC;CAC3B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/hooks/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC"}
|
package/hooks/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useComponentOutsideClick';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DependencyList } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Subscribe to component outside click
|
|
4
|
+
* @param selector Component root selector
|
|
5
|
+
* @param clickHandleCondition Condition to handle document click
|
|
6
|
+
* @param clickHandleChange Handler of outside component click
|
|
7
|
+
* @param clickListenCondition Condition to start listening document clicks
|
|
8
|
+
* @param dependencies Additional dependencies to update hook
|
|
9
|
+
*/
|
|
10
|
+
export declare const useComponentOutsideClick: (selector: string, clickHandleCondition: boolean, clickHandleChange: () => void, clickListenCondition?: boolean, dependencies?: DependencyList) => void;
|
|
11
|
+
//# sourceMappingURL=useComponentOutsideClick.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useComponentOutsideClick.d.ts","sourceRoot":"","sources":["../../src/hooks/useComponentOutsideClick.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAA0B,MAAM,OAAO,CAAC;AAI/D;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,aACvB,MAAM,wBACM,OAAO,qBACV,MAAM,IAAI,yBACN,OAAO,iBACf,cAAc,KAC9B,IA6BF,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useCallback, useEffect } from "react";
|
|
2
|
+
import utils from "@bodynarf/utils";
|
|
3
|
+
/**
|
|
4
|
+
* Subscribe to component outside click
|
|
5
|
+
* @param selector Component root selector
|
|
6
|
+
* @param clickHandleCondition Condition to handle document click
|
|
7
|
+
* @param clickHandleChange Handler of outside component click
|
|
8
|
+
* @param clickListenCondition Condition to start listening document clicks
|
|
9
|
+
* @param dependencies Additional dependencies to update hook
|
|
10
|
+
*/
|
|
11
|
+
export const useComponentOutsideClick = (selector, clickHandleCondition, clickHandleChange, clickListenCondition, dependencies) => {
|
|
12
|
+
const onDocumentClick = useCallback((event) => {
|
|
13
|
+
if (clickHandleCondition) {
|
|
14
|
+
const target = event.target;
|
|
15
|
+
if (utils.isNullOrUndefined(target)) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const relatedComponent = target.closest(selector);
|
|
19
|
+
if (utils.isNull(relatedComponent)) {
|
|
20
|
+
clickHandleChange();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
24
|
+
}, [clickHandleCondition, selector, clickHandleChange, dependencies]);
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
if (utils.isNullOrUndefined(clickListenCondition) || clickListenCondition === true) {
|
|
27
|
+
document.addEventListener('click', onDocumentClick);
|
|
28
|
+
return () => document.removeEventListener('click', onDocumentClick);
|
|
29
|
+
}
|
|
30
|
+
return () => { };
|
|
31
|
+
}, [clickListenCondition, onDocumentClick]);
|
|
32
|
+
};
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './components/types';
|
|
2
|
+
export * from './components/anchor';
|
|
3
|
+
export * from './components/button';
|
|
4
|
+
export * from './components/dropdown';
|
|
5
|
+
export * from './components/icon';
|
|
6
|
+
export * from './components/primitives';
|
|
7
|
+
export * from './components/search';
|
|
8
|
+
export * from './components/types';
|
|
9
|
+
export * from './hooks';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
package/index.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,SAAS,CAAC"}
|
package/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './components/types';
|
|
2
|
+
export * from './components/anchor';
|
|
3
|
+
export * from './components/button';
|
|
4
|
+
export * from './components/dropdown';
|
|
5
|
+
export * from './components/icon';
|
|
6
|
+
export * from './components/primitives';
|
|
7
|
+
export * from './components/search';
|
|
8
|
+
export * from './components/types';
|
|
9
|
+
export * from './hooks';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bodynarf/react.components",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "Artem",
|
|
6
6
|
"email": "bodynar@gmail.com"
|
|
@@ -20,25 +20,15 @@
|
|
|
20
20
|
"react component",
|
|
21
21
|
"bulma"
|
|
22
22
|
],
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@types/react": "^18.0.11",
|
|
25
|
+
"@types/react-dom": "^18.0.5",
|
|
26
|
+
"typescript": "^4.7.3"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"
|
|
30
|
-
"react": "^18.
|
|
31
|
-
"react-dom": "^18.
|
|
32
|
-
|
|
33
|
-
"devDependencies": {
|
|
34
|
-
"@bodynarf/utils": "^1.0.0",
|
|
35
|
-
"@types/node": "^17.0.25",
|
|
36
|
-
"@types/react": "^18.0.5",
|
|
37
|
-
"@types/react-dom": "^18.0.1",
|
|
38
|
-
"@vitejs/plugin-react": "^1.3.0",
|
|
39
|
-
"bulma": "^0.9.3",
|
|
40
|
-
"sass": "^1.50.1",
|
|
41
|
-
"typescript": "^4.6.3",
|
|
42
|
-
"vite": "^2.9.2"
|
|
29
|
+
"@bodynarf/utils": "^1.0.10",
|
|
30
|
+
"react": "^18.1.0",
|
|
31
|
+
"react-dom": "^18.1.0",
|
|
32
|
+
"bulma": "^0.9.4"
|
|
43
33
|
}
|
|
44
34
|
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: Bug report
|
|
3
|
-
about: Create a report to help us improve
|
|
4
|
-
title: "[Bug]"
|
|
5
|
-
labels: bug
|
|
6
|
-
assignees: bodynar
|
|
7
|
-
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
**Describe the bug**
|
|
11
|
-
A clear and concise description of what the bug is.
|
|
12
|
-
|
|
13
|
-
**To Reproduce**
|
|
14
|
-
Steps to reproduce the behavior:
|
|
15
|
-
1. Go to '...'
|
|
16
|
-
2. Click on '....'
|
|
17
|
-
|
|
18
|
-
**Expected behavior**
|
|
19
|
-
A clear and concise description of what you expected to happen.
|
|
20
|
-
|
|
21
|
-
**Screenshots**
|
|
22
|
-
If applicable, add screenshots to help explain your problem.
|
|
23
|
-
|
|
24
|
-
**Additional context**
|
|
25
|
-
Add any other context about the problem here.
|
package/index.html
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<base href="/"/>
|
|
5
|
-
<meta charset="UTF-8">
|
|
6
|
-
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
|
7
|
-
<title>bodynarf/react-components</title>
|
|
8
|
-
</head>
|
|
9
|
-
<body>
|
|
10
|
-
<div id="root"></div>
|
|
11
|
-
<script type="module" src="/src/main.tsx"></script>
|
|
12
|
-
</body>
|
|
13
|
-
</html>
|