@bodynarf/react.components 1.1.0 → 1.1.5
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/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/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 +29 -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 +20 -0
- package/components/dropdown/index.d.ts +31 -0
- package/components/dropdown/index.d.ts.map +1 -0
- package/components/dropdown/index.js +55 -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/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 +41 -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 +10 -21
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -25
- package/anchor.ts +0 -10
- package/button.ts +0 -11
- package/date.ts +0 -7
- package/dropdown.ts +0 -9
- package/hooks.ts +0 -5
- package/icon.ts +0 -7
- package/index.html +0 -13
- package/index.ts +0 -14
- package/multiline.ts +0 -7
- package/search.ts +0 -7
- package/src/components/anchor/anchor.scss +0 -15
- 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/button.scss +0 -12
- 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/dropdown.scss +0 -89
- package/src/components/dropdown/index.tsx +0 -141
- package/src/components/icon/icon.scss +0 -18
- 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/components/search/search.scss +0 -24
- package/src/hooks/useComponentOutsideClick.ts +0 -48
- package/src/main.tsx +0 -9
- package/text.ts +0 -7
- package/tsconfig.json +0 -49
- package/tsconfig.node.json +0 -8
- package/vite.config.ts +0 -14
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import { ChangeEvent, useCallback, useState } from 'react';
|
|
2
|
-
|
|
3
|
-
import './search.scss';
|
|
4
|
-
|
|
5
|
-
import { generateGuid } from '@bodynarf/utils/guid';
|
|
6
|
-
import { isNullOrUndefined } from '@bodynarf/utils/common';
|
|
7
|
-
|
|
8
|
-
import Button from '@app/components/button';
|
|
9
|
-
|
|
10
|
-
export type SearchProps = {
|
|
11
|
-
/** Search caption */
|
|
12
|
-
caption: string;
|
|
13
|
-
|
|
14
|
-
/** Search handler */
|
|
15
|
-
onSearch: (searchPattern: string) => void;
|
|
16
|
-
|
|
17
|
-
/** Initial search value */
|
|
18
|
-
defaultValue?: string;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Search type: by typing, starts from minimum characters to search
|
|
22
|
-
* or by clicking on button next to search bar.
|
|
23
|
-
* Default is byTyping
|
|
24
|
-
*/
|
|
25
|
-
searchType?: 'byTyping' | 'byButton';
|
|
26
|
-
|
|
27
|
-
/** Control name. If empty - will be replaced by random guid */
|
|
28
|
-
name?: string;
|
|
29
|
-
|
|
30
|
-
/** Minimum amount of characters to search */
|
|
31
|
-
minCharsToSearch?: number;
|
|
32
|
-
|
|
33
|
-
/** Size of search bar */
|
|
34
|
-
size?: 'small' | 'normal' | 'medium' | 'large';
|
|
35
|
-
|
|
36
|
-
/** Should search bar be rounded */
|
|
37
|
-
rounded?: boolean;
|
|
38
|
-
|
|
39
|
-
/** Is search bar disabled */
|
|
40
|
-
disabled?: boolean;
|
|
41
|
-
|
|
42
|
-
/** Should loading icon be displayed in search bar*/
|
|
43
|
-
isLoading?: boolean;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
/** Search component */
|
|
47
|
-
export default function Search(props: SearchProps): JSX.Element {
|
|
48
|
-
const [name] = useState<string>(props.name || generateGuid());
|
|
49
|
-
const [searchValue, setSearchValue] = useState<string>(props.defaultValue || '');
|
|
50
|
-
|
|
51
|
-
const searchType = props.searchType || 'byTyping';
|
|
52
|
-
|
|
53
|
-
const onChange = useCallback(
|
|
54
|
-
(event: ChangeEvent<HTMLInputElement>) => {
|
|
55
|
-
const elementValue: string = event.target.value;
|
|
56
|
-
|
|
57
|
-
if (searchType === 'byTyping') {
|
|
58
|
-
const minCharsToSearch: number =
|
|
59
|
-
isNullOrUndefined(props.minCharsToSearch)
|
|
60
|
-
? 3
|
|
61
|
-
: props.minCharsToSearch as number;
|
|
62
|
-
|
|
63
|
-
if (elementValue.length >= minCharsToSearch) {
|
|
64
|
-
props.onSearch(elementValue);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
setSearchValue(elementValue);
|
|
69
|
-
}, [props, searchType]);
|
|
70
|
-
|
|
71
|
-
const onSearchButtonClick = useCallback(
|
|
72
|
-
() => {
|
|
73
|
-
props.onSearch(searchValue);
|
|
74
|
-
}, [props, searchValue]);
|
|
75
|
-
|
|
76
|
-
const className: string = 'app-search control'
|
|
77
|
-
+ ` is-${(props.size || 'normal')}`
|
|
78
|
-
+ (props.isLoading === true ? ' is-loading' : '')
|
|
79
|
-
+ (searchType === 'byButton' ? ' is-expanded': '')
|
|
80
|
-
;
|
|
81
|
-
|
|
82
|
-
const inputClassName: string = 'input is-unselectable'
|
|
83
|
-
+ ` is-${(props.size || 'normal')}`
|
|
84
|
-
+ (props.rounded === true ? ' is-rounded' : '')
|
|
85
|
-
;
|
|
86
|
-
|
|
87
|
-
if (searchType === 'byButton') {
|
|
88
|
-
return (
|
|
89
|
-
<div className="field has-addons">
|
|
90
|
-
<div className={className}>
|
|
91
|
-
<input
|
|
92
|
-
type='search'
|
|
93
|
-
name={name}
|
|
94
|
-
defaultValue={searchValue}
|
|
95
|
-
className={inputClassName}
|
|
96
|
-
disabled={props.disabled}
|
|
97
|
-
onChange={onChange}
|
|
98
|
-
placeholder={props.caption}
|
|
99
|
-
/>
|
|
100
|
-
</div>
|
|
101
|
-
<div className="control">
|
|
102
|
-
<Button
|
|
103
|
-
caption="Search"
|
|
104
|
-
type="info"
|
|
105
|
-
onClick={onSearchButtonClick}
|
|
106
|
-
isLoading={props.isLoading}
|
|
107
|
-
/>
|
|
108
|
-
</div>
|
|
109
|
-
</div>
|
|
110
|
-
);
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
return (
|
|
114
|
-
<div className={className}>
|
|
115
|
-
<input
|
|
116
|
-
type='search'
|
|
117
|
-
name={name}
|
|
118
|
-
defaultValue={searchValue}
|
|
119
|
-
className={inputClassName}
|
|
120
|
-
disabled={props.disabled}
|
|
121
|
-
onChange={onChange}
|
|
122
|
-
placeholder={props.caption}
|
|
123
|
-
/>
|
|
124
|
-
</div>
|
|
125
|
-
);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
.app-search {
|
|
2
|
-
input[type="search"] {
|
|
3
|
-
transition: 0.15s ease-out;
|
|
4
|
-
transition-property: border-color, color, background-color;
|
|
5
|
-
|
|
6
|
-
&::placeholder {
|
|
7
|
-
user-select: none;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
&::-webkit-input-placeholder {
|
|
11
|
-
transition: 0.15s ease-out color;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
&::-webkit-search-cancel-button {
|
|
15
|
-
cursor: pointer;
|
|
16
|
-
font-size: 1.25rem;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
&.is-loading::after {
|
|
21
|
-
right: 1rem;
|
|
22
|
-
top: 0.725rem;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { DependencyList, useCallback, useEffect } from "react";
|
|
2
|
-
|
|
3
|
-
import { isNull, isNullOrUndefined } from "@bodynarf/utils/common";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Subscribe to component outside click
|
|
7
|
-
* @param selector Component root selector
|
|
8
|
-
* @param clickHandleCondition Condition to handle document click
|
|
9
|
-
* @param clickHandleChange Handler of outside component click
|
|
10
|
-
* @param clickListenCondition Condition to start listening document clicks
|
|
11
|
-
* @param dependencies Additional dependencies to update hook
|
|
12
|
-
*/
|
|
13
|
-
export const useComponentOutsideClick = (
|
|
14
|
-
selector: string,
|
|
15
|
-
clickHandleCondition: boolean,
|
|
16
|
-
clickHandleChange: () => void,
|
|
17
|
-
clickListenCondition?: boolean,
|
|
18
|
-
dependencies?: DependencyList
|
|
19
|
-
): void => {
|
|
20
|
-
const onDocumentClick = useCallback(
|
|
21
|
-
(event: MouseEvent): void => {
|
|
22
|
-
if (clickHandleCondition) {
|
|
23
|
-
const target: HTMLElement = event.target as HTMLElement;
|
|
24
|
-
|
|
25
|
-
if (isNullOrUndefined(target)) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const relatedComponent: Element | null =
|
|
30
|
-
target.closest(selector);
|
|
31
|
-
|
|
32
|
-
if (isNull(relatedComponent)) {
|
|
33
|
-
clickHandleChange();
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
37
|
-
}, [clickHandleCondition, selector, clickHandleChange, dependencies]);
|
|
38
|
-
|
|
39
|
-
useEffect(() => {
|
|
40
|
-
if (isNullOrUndefined(clickListenCondition) || clickListenCondition === true) {
|
|
41
|
-
document.addEventListener('click', onDocumentClick);
|
|
42
|
-
|
|
43
|
-
return (): void => document.removeEventListener('click', onDocumentClick);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return () => { };
|
|
47
|
-
}, [clickListenCondition, onDocumentClick]);
|
|
48
|
-
};
|
package/src/main.tsx
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { createRoot } from "react-dom/client";
|
|
2
|
-
|
|
3
|
-
import "bootstrap-icons/font/bootstrap-icons.css";
|
|
4
|
-
import "bulma/bulma.sass";
|
|
5
|
-
|
|
6
|
-
const container = document.getElementById("root");
|
|
7
|
-
|
|
8
|
-
const root = createRoot(container!); // createRoot(container!) if you use TypeScript
|
|
9
|
-
root.render(<div> Components </div>);
|
package/text.ts
DELETED
package/tsconfig.json
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ESNext",
|
|
4
|
-
"useDefineForClassFields": true,
|
|
5
|
-
"lib": [
|
|
6
|
-
"DOM",
|
|
7
|
-
"DOM.Iterable",
|
|
8
|
-
"ESNext"
|
|
9
|
-
],
|
|
10
|
-
"allowJs": false,
|
|
11
|
-
"skipLibCheck": false,
|
|
12
|
-
"esModuleInterop": false,
|
|
13
|
-
"allowSyntheticDefaultImports": true,
|
|
14
|
-
"strict": true,
|
|
15
|
-
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
|
16
|
-
"noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
|
|
17
|
-
"alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
|
|
18
|
-
"forceConsistentCasingInFileNames": true,
|
|
19
|
-
"module": "ESNext",
|
|
20
|
-
"moduleResolution": "Node",
|
|
21
|
-
"resolveJsonModule": true,
|
|
22
|
-
// "isolatedModules": true,
|
|
23
|
-
"noEmit": true,
|
|
24
|
-
"jsx": "react-jsx",
|
|
25
|
-
"downlevelIteration": true,
|
|
26
|
-
"noUnusedLocals": true, /* Report errors on unused locals. */
|
|
27
|
-
"noUnusedParameters": true, /* Report errors on unused parameters. */
|
|
28
|
-
"noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
|
29
|
-
"baseUrl": "./", /* Base directory to resolve non-absolute module names. */
|
|
30
|
-
"paths": {
|
|
31
|
-
"@app/components/*": [
|
|
32
|
-
"src/components/*",
|
|
33
|
-
"src/components/primitives/*"
|
|
34
|
-
],
|
|
35
|
-
"@app/hooks/*": [
|
|
36
|
-
"src/hooks/*"
|
|
37
|
-
],
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
"include": [
|
|
41
|
-
"src",
|
|
42
|
-
"./"
|
|
43
|
-
],
|
|
44
|
-
"references": [
|
|
45
|
-
{
|
|
46
|
-
"path": "./tsconfig.node.json"
|
|
47
|
-
}
|
|
48
|
-
],
|
|
49
|
-
}
|
package/tsconfig.node.json
DELETED
package/vite.config.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { defineConfig, splitVendorChunkPlugin } from 'vite';
|
|
2
|
-
|
|
3
|
-
import react from '@vitejs/plugin-react';
|
|
4
|
-
|
|
5
|
-
// https://vitejs.dev/config/
|
|
6
|
-
export default defineConfig({
|
|
7
|
-
plugins: [
|
|
8
|
-
splitVendorChunkPlugin(),
|
|
9
|
-
react(),
|
|
10
|
-
],
|
|
11
|
-
build: {
|
|
12
|
-
sourcemap: true,
|
|
13
|
-
}
|
|
14
|
-
});
|