@bodynarf/react.components 1.7.2 → 1.7.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/dist/package.json +41 -0
- package/dist/readme.md +56 -0
- package/package.json +5 -3
- package/src/common.scss +3 -0
- package/src/components/accordion/component/index.tsx +84 -0
- package/src/components/accordion/index.ts +2 -0
- package/src/components/accordion/types.ts +22 -0
- package/src/components/anchor/component/index.tsx +40 -0
- package/src/components/anchor/component/style.scss +15 -0
- package/src/components/anchor/components/anchorWithIcon/index.tsx +45 -0
- package/src/components/anchor/components/simpleAnchor/index.tsx +16 -0
- package/src/components/anchor/index.ts +2 -0
- package/src/components/anchor/types.ts +54 -0
- package/src/components/button/component/index.tsx +58 -0
- package/src/components/button/component/style.scss +12 -0
- package/src/components/button/components/buttonWithIcon/index.tsx +53 -0
- package/src/components/button/components/simpleButton/index.tsx +21 -0
- package/src/components/button/index.ts +2 -0
- package/src/components/button/types.ts +64 -0
- package/src/components/dropdown/component/index.tsx +20 -0
- package/src/components/dropdown/component/style.scss +120 -0
- package/src/components/dropdown/components/compact/index.tsx +121 -0
- package/src/components/dropdown/components/item/index.tsx +30 -0
- package/src/components/dropdown/components/label/index.tsx +68 -0
- package/src/components/dropdown/components/withLabel/index.tsx +201 -0
- package/src/components/dropdown/index.ts +2 -0
- package/src/components/dropdown/types.ts +59 -0
- package/src/components/icon/component/index.tsx +34 -0
- package/src/components/icon/component/style.scss +21 -0
- package/src/components/icon/index.ts +2 -0
- package/src/components/icon/types.ts +18 -0
- package/src/components/index.ts +13 -0
- package/src/components/paginator/component/index.tsx +131 -0
- package/src/components/paginator/index.ts +3 -0
- package/src/components/paginator/types.ts +40 -0
- package/src/components/paginator/utils.ts +19 -0
- package/src/components/primitives/checkbox/component/index.tsx +102 -0
- package/src/components/primitives/checkbox/component/style.scss +10 -0
- package/src/components/primitives/checkbox/index.ts +2 -0
- package/src/components/primitives/checkbox/types.ts +29 -0
- package/src/components/primitives/date/component/index.tsx +129 -0
- package/src/components/primitives/date/index.ts +2 -0
- package/src/components/primitives/date/types.ts +10 -0
- package/src/components/primitives/index.ts +7 -0
- package/src/components/primitives/multiline/component/index.tsx +20 -0
- package/src/components/primitives/multiline/components/multilineWithLabel/index.tsx +125 -0
- package/src/components/primitives/multiline/components/multilineWithoutLabel/index.tsx +62 -0
- package/src/components/primitives/multiline/index.ts +2 -0
- package/src/components/primitives/multiline/types.ts +13 -0
- package/src/components/primitives/number/component/index.tsx +17 -0
- package/src/components/primitives/number/components/withLabel/index.tsx +127 -0
- package/src/components/primitives/number/components/withoutLabel/index.tsx +66 -0
- package/src/components/primitives/number/index.ts +2 -0
- package/src/components/primitives/number/types.ts +14 -0
- package/src/components/primitives/password/component/index.tsx +19 -0
- package/src/components/primitives/password/component/style.scss +16 -0
- package/src/components/primitives/password/components/withLabel/index.tsx +147 -0
- package/src/components/primitives/password/components/withoutLabel/index.tsx +79 -0
- package/src/components/primitives/password/index.ts +2 -0
- package/src/components/primitives/password/types.ts +10 -0
- package/src/components/primitives/text/component/index.tsx +20 -0
- package/src/components/primitives/text/components/textWithLabel/index.tsx +123 -0
- package/src/components/primitives/text/components/textWithoutLabel/index.tsx +64 -0
- package/src/components/primitives/text/index.tsx +2 -0
- package/src/components/primitives/text/types.ts +7 -0
- package/src/components/primitives/types/baseProps.ts +42 -0
- package/src/components/primitives/types/index.ts +3 -0
- package/src/components/primitives/types/label.ts +17 -0
- package/src/components/primitives/types/validation/index.ts +2 -0
- package/src/components/primitives/types/validation/state.ts +10 -0
- package/src/components/primitives/types/validation/status.ts +11 -0
- package/src/components/search/component/index.tsx +88 -0
- package/src/components/search/component/style.scss +24 -0
- package/src/components/search/index.ts +2 -0
- package/src/components/search/types.ts +35 -0
- package/src/components/tabs/component/index.tsx +147 -0
- package/src/components/tabs/component/style.scss +12 -0
- package/src/components/tabs/components/item/index.tsx +86 -0
- package/src/components/tabs/index.ts +2 -0
- package/src/components/tabs/types.ts +52 -0
- package/src/components/tag/component/index.tsx +52 -0
- package/src/components/tag/component/style.scss +27 -0
- package/src/components/tag/index.ts +2 -0
- package/src/components/tag/types.ts +34 -0
- package/src/components/types.ts +87 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useComponentOutsideClick.ts +48 -0
- package/src/hooks/usePagination.ts +55 -0
- package/src/index.ts +3 -0
- package/src/utils/dataAttributes.ts +26 -0
- package/src/utils/formValidation.ts +42 -0
- package/src/utils/index.ts +2 -0
- package/tsconfig.json +42 -0
- /package/{components → dist/components}/accordion/component/index.d.ts +0 -0
- /package/{components → dist/components}/accordion/component/index.d.ts.map +0 -0
- /package/{components → dist/components}/accordion/component/index.js +0 -0
- /package/{components → dist/components}/accordion/index.d.ts +0 -0
- /package/{components → dist/components}/accordion/index.d.ts.map +0 -0
- /package/{components → dist/components}/accordion/index.js +0 -0
- /package/{components → dist/components}/accordion/types.d.ts +0 -0
- /package/{components → dist/components}/accordion/types.d.ts.map +0 -0
- /package/{components → dist/components}/accordion/types.js +0 -0
- /package/{components → dist/components}/anchor/component/index.d.ts +0 -0
- /package/{components → dist/components}/anchor/component/index.d.ts.map +0 -0
- /package/{components → dist/components}/anchor/component/index.js +0 -0
- /package/{components → dist/components}/anchor/components/anchorWithIcon/index.d.ts +0 -0
- /package/{components → dist/components}/anchor/components/anchorWithIcon/index.d.ts.map +0 -0
- /package/{components → dist/components}/anchor/components/anchorWithIcon/index.js +0 -0
- /package/{components → dist/components}/anchor/components/simpleAnchor/index.d.ts +0 -0
- /package/{components → dist/components}/anchor/components/simpleAnchor/index.d.ts.map +0 -0
- /package/{components → dist/components}/anchor/components/simpleAnchor/index.js +0 -0
- /package/{components → dist/components}/anchor/index.d.ts +0 -0
- /package/{components → dist/components}/anchor/index.d.ts.map +0 -0
- /package/{components → dist/components}/anchor/index.js +0 -0
- /package/{components → dist/components}/anchor/types.d.ts +0 -0
- /package/{components → dist/components}/anchor/types.d.ts.map +0 -0
- /package/{components → dist/components}/anchor/types.js +0 -0
- /package/{components → dist/components}/button/component/index.d.ts +0 -0
- /package/{components → dist/components}/button/component/index.d.ts.map +0 -0
- /package/{components → dist/components}/button/component/index.js +0 -0
- /package/{components → dist/components}/button/components/buttonWithIcon/index.d.ts +0 -0
- /package/{components → dist/components}/button/components/buttonWithIcon/index.d.ts.map +0 -0
- /package/{components → dist/components}/button/components/buttonWithIcon/index.js +0 -0
- /package/{components → dist/components}/button/components/simpleButton/index.d.ts +0 -0
- /package/{components → dist/components}/button/components/simpleButton/index.d.ts.map +0 -0
- /package/{components → dist/components}/button/components/simpleButton/index.js +0 -0
- /package/{components → dist/components}/button/index.d.ts +0 -0
- /package/{components → dist/components}/button/index.d.ts.map +0 -0
- /package/{components → dist/components}/button/index.js +0 -0
- /package/{components → dist/components}/button/types.d.ts +0 -0
- /package/{components → dist/components}/button/types.d.ts.map +0 -0
- /package/{components → dist/components}/button/types.js +0 -0
- /package/{components → dist/components}/dropdown/component/index.d.ts +0 -0
- /package/{components → dist/components}/dropdown/component/index.d.ts.map +0 -0
- /package/{components → dist/components}/dropdown/component/index.js +0 -0
- /package/{components → dist/components}/dropdown/components/compact/index.d.ts +0 -0
- /package/{components → dist/components}/dropdown/components/compact/index.d.ts.map +0 -0
- /package/{components → dist/components}/dropdown/components/compact/index.js +0 -0
- /package/{components → dist/components}/dropdown/components/item/index.d.ts +0 -0
- /package/{components → dist/components}/dropdown/components/item/index.d.ts.map +0 -0
- /package/{components → dist/components}/dropdown/components/item/index.js +0 -0
- /package/{components → dist/components}/dropdown/components/label/index.d.ts +0 -0
- /package/{components → dist/components}/dropdown/components/label/index.d.ts.map +0 -0
- /package/{components → dist/components}/dropdown/components/label/index.js +0 -0
- /package/{components → dist/components}/dropdown/components/withLabel/index.d.ts +0 -0
- /package/{components → dist/components}/dropdown/components/withLabel/index.d.ts.map +0 -0
- /package/{components → dist/components}/dropdown/components/withLabel/index.js +0 -0
- /package/{components → dist/components}/dropdown/index.d.ts +0 -0
- /package/{components → dist/components}/dropdown/index.d.ts.map +0 -0
- /package/{components → dist/components}/dropdown/index.js +0 -0
- /package/{components → dist/components}/dropdown/types.d.ts +0 -0
- /package/{components → dist/components}/dropdown/types.d.ts.map +0 -0
- /package/{components → dist/components}/dropdown/types.js +0 -0
- /package/{components → dist/components}/icon/component/index.d.ts +0 -0
- /package/{components → dist/components}/icon/component/index.d.ts.map +0 -0
- /package/{components → dist/components}/icon/component/index.js +0 -0
- /package/{components → dist/components}/icon/index.d.ts +0 -0
- /package/{components → dist/components}/icon/index.d.ts.map +0 -0
- /package/{components → dist/components}/icon/index.js +0 -0
- /package/{components → dist/components}/icon/types.d.ts +0 -0
- /package/{components → dist/components}/icon/types.d.ts.map +0 -0
- /package/{components → dist/components}/icon/types.js +0 -0
- /package/{components → dist/components}/index.d.ts +0 -0
- /package/{components → dist/components}/index.d.ts.map +0 -0
- /package/{components → dist/components}/index.js +0 -0
- /package/{components → dist/components}/paginator/component/index.d.ts +0 -0
- /package/{components → dist/components}/paginator/component/index.d.ts.map +0 -0
- /package/{components → dist/components}/paginator/component/index.js +0 -0
- /package/{components → dist/components}/paginator/index.d.ts +0 -0
- /package/{components → dist/components}/paginator/index.d.ts.map +0 -0
- /package/{components → dist/components}/paginator/index.js +0 -0
- /package/{components → dist/components}/paginator/types.d.ts +0 -0
- /package/{components → dist/components}/paginator/types.d.ts.map +0 -0
- /package/{components → dist/components}/paginator/types.js +0 -0
- /package/{components → dist/components}/paginator/utils.d.ts +0 -0
- /package/{components → dist/components}/paginator/utils.d.ts.map +0 -0
- /package/{components → dist/components}/paginator/utils.js +0 -0
- /package/{components → dist/components}/primitives/checkbox/component/index.d.ts +0 -0
- /package/{components → dist/components}/primitives/checkbox/component/index.d.ts.map +0 -0
- /package/{components → dist/components}/primitives/checkbox/component/index.js +0 -0
- /package/{components → dist/components}/primitives/checkbox/index.d.ts +0 -0
- /package/{components → dist/components}/primitives/checkbox/index.d.ts.map +0 -0
- /package/{components → dist/components}/primitives/checkbox/index.js +0 -0
- /package/{components → dist/components}/primitives/checkbox/types.d.ts +0 -0
- /package/{components → dist/components}/primitives/checkbox/types.d.ts.map +0 -0
- /package/{components → dist/components}/primitives/checkbox/types.js +0 -0
- /package/{components → dist/components}/primitives/date/component/index.d.ts +0 -0
- /package/{components → dist/components}/primitives/date/component/index.d.ts.map +0 -0
- /package/{components → dist/components}/primitives/date/component/index.js +0 -0
- /package/{components → dist/components}/primitives/date/index.d.ts +0 -0
- /package/{components → dist/components}/primitives/date/index.d.ts.map +0 -0
- /package/{components → dist/components}/primitives/date/index.js +0 -0
- /package/{components → dist/components}/primitives/date/types.d.ts +0 -0
- /package/{components → dist/components}/primitives/date/types.d.ts.map +0 -0
- /package/{components → dist/components}/primitives/date/types.js +0 -0
- /package/{components → dist/components}/primitives/index.d.ts +0 -0
- /package/{components → dist/components}/primitives/index.d.ts.map +0 -0
- /package/{components → dist/components}/primitives/index.js +0 -0
- /package/{components → dist/components}/primitives/multiline/component/index.d.ts +0 -0
- /package/{components → dist/components}/primitives/multiline/component/index.d.ts.map +0 -0
- /package/{components → dist/components}/primitives/multiline/component/index.js +0 -0
- /package/{components → dist/components}/primitives/multiline/components/multilineWithLabel/index.d.ts +0 -0
- /package/{components → dist/components}/primitives/multiline/components/multilineWithLabel/index.d.ts.map +0 -0
- /package/{components → dist/components}/primitives/multiline/components/multilineWithLabel/index.js +0 -0
- /package/{components → dist/components}/primitives/multiline/components/multilineWithoutLabel/index.d.ts +0 -0
- /package/{components → dist/components}/primitives/multiline/components/multilineWithoutLabel/index.d.ts.map +0 -0
- /package/{components → dist/components}/primitives/multiline/components/multilineWithoutLabel/index.js +0 -0
- /package/{components → dist/components}/primitives/multiline/index.d.ts +0 -0
- /package/{components → dist/components}/primitives/multiline/index.d.ts.map +0 -0
- /package/{components → dist/components}/primitives/multiline/index.js +0 -0
- /package/{components → dist/components}/primitives/multiline/types.d.ts +0 -0
- /package/{components → dist/components}/primitives/multiline/types.d.ts.map +0 -0
- /package/{components → dist/components}/primitives/multiline/types.js +0 -0
- /package/{components → dist/components}/primitives/number/component/index.d.ts +0 -0
- /package/{components → dist/components}/primitives/number/component/index.d.ts.map +0 -0
- /package/{components → dist/components}/primitives/number/component/index.js +0 -0
- /package/{components → dist/components}/primitives/number/components/withLabel/index.d.ts +0 -0
- /package/{components → dist/components}/primitives/number/components/withLabel/index.d.ts.map +0 -0
- /package/{components → dist/components}/primitives/number/components/withLabel/index.js +0 -0
- /package/{components → dist/components}/primitives/number/components/withoutLabel/index.d.ts +0 -0
- /package/{components → dist/components}/primitives/number/components/withoutLabel/index.d.ts.map +0 -0
- /package/{components → dist/components}/primitives/number/components/withoutLabel/index.js +0 -0
- /package/{components → dist/components}/primitives/number/index.d.ts +0 -0
- /package/{components → dist/components}/primitives/number/index.d.ts.map +0 -0
- /package/{components → dist/components}/primitives/number/index.js +0 -0
- /package/{components → dist/components}/primitives/number/types.d.ts +0 -0
- /package/{components → dist/components}/primitives/number/types.d.ts.map +0 -0
- /package/{components → dist/components}/primitives/number/types.js +0 -0
- /package/{components → dist/components}/primitives/password/component/index.d.ts +0 -0
- /package/{components → dist/components}/primitives/password/component/index.d.ts.map +0 -0
- /package/{components → dist/components}/primitives/password/component/index.js +0 -0
- /package/{components → dist/components}/primitives/password/components/withLabel/index.d.ts +0 -0
- /package/{components → dist/components}/primitives/password/components/withLabel/index.d.ts.map +0 -0
- /package/{components → dist/components}/primitives/password/components/withLabel/index.js +0 -0
- /package/{components → dist/components}/primitives/password/components/withoutLabel/index.d.ts +0 -0
- /package/{components → dist/components}/primitives/password/components/withoutLabel/index.d.ts.map +0 -0
- /package/{components → dist/components}/primitives/password/components/withoutLabel/index.js +0 -0
- /package/{components → dist/components}/primitives/password/index.d.ts +0 -0
- /package/{components → dist/components}/primitives/password/index.d.ts.map +0 -0
- /package/{components → dist/components}/primitives/password/index.js +0 -0
- /package/{components → dist/components}/primitives/password/types.d.ts +0 -0
- /package/{components → dist/components}/primitives/password/types.d.ts.map +0 -0
- /package/{components → dist/components}/primitives/password/types.js +0 -0
- /package/{components → dist/components}/primitives/text/component/index.d.ts +0 -0
- /package/{components → dist/components}/primitives/text/component/index.d.ts.map +0 -0
- /package/{components → dist/components}/primitives/text/component/index.js +0 -0
- /package/{components → dist/components}/primitives/text/components/textWithLabel/index.d.ts +0 -0
- /package/{components → dist/components}/primitives/text/components/textWithLabel/index.d.ts.map +0 -0
- /package/{components → dist/components}/primitives/text/components/textWithLabel/index.js +0 -0
- /package/{components → dist/components}/primitives/text/components/textWithoutLabel/index.d.ts +0 -0
- /package/{components → dist/components}/primitives/text/components/textWithoutLabel/index.d.ts.map +0 -0
- /package/{components → dist/components}/primitives/text/components/textWithoutLabel/index.js +0 -0
- /package/{components → dist/components}/primitives/text/index.d.ts +0 -0
- /package/{components → dist/components}/primitives/text/index.d.ts.map +0 -0
- /package/{components → dist/components}/primitives/text/index.js +0 -0
- /package/{components → dist/components}/primitives/text/types.d.ts +0 -0
- /package/{components → dist/components}/primitives/text/types.d.ts.map +0 -0
- /package/{components → dist/components}/primitives/text/types.js +0 -0
- /package/{components → dist/components}/primitives/types/baseProps.d.ts +0 -0
- /package/{components → dist/components}/primitives/types/baseProps.d.ts.map +0 -0
- /package/{components → dist/components}/primitives/types/baseProps.js +0 -0
- /package/{components → dist/components}/primitives/types/index.d.ts +0 -0
- /package/{components → dist/components}/primitives/types/index.d.ts.map +0 -0
- /package/{components → dist/components}/primitives/types/index.js +0 -0
- /package/{components → dist/components}/primitives/types/label.d.ts +0 -0
- /package/{components → dist/components}/primitives/types/label.d.ts.map +0 -0
- /package/{components → dist/components}/primitives/types/label.js +0 -0
- /package/{components → dist/components}/primitives/types/validation/index.d.ts +0 -0
- /package/{components → dist/components}/primitives/types/validation/index.d.ts.map +0 -0
- /package/{components → dist/components}/primitives/types/validation/index.js +0 -0
- /package/{components → dist/components}/primitives/types/validation/state.d.ts +0 -0
- /package/{components → dist/components}/primitives/types/validation/state.d.ts.map +0 -0
- /package/{components → dist/components}/primitives/types/validation/state.js +0 -0
- /package/{components → dist/components}/primitives/types/validation/status.d.ts +0 -0
- /package/{components → dist/components}/primitives/types/validation/status.d.ts.map +0 -0
- /package/{components → dist/components}/primitives/types/validation/status.js +0 -0
- /package/{components → dist/components}/search/component/index.d.ts +0 -0
- /package/{components → dist/components}/search/component/index.d.ts.map +0 -0
- /package/{components → dist/components}/search/component/index.js +0 -0
- /package/{components → dist/components}/search/index.d.ts +0 -0
- /package/{components → dist/components}/search/index.d.ts.map +0 -0
- /package/{components → dist/components}/search/index.js +0 -0
- /package/{components → dist/components}/search/types.d.ts +0 -0
- /package/{components → dist/components}/search/types.d.ts.map +0 -0
- /package/{components → dist/components}/search/types.js +0 -0
- /package/{components → dist/components}/tabs/component/index.d.ts +0 -0
- /package/{components → dist/components}/tabs/component/index.d.ts.map +0 -0
- /package/{components → dist/components}/tabs/component/index.js +0 -0
- /package/{components → dist/components}/tabs/components/item/index.d.ts +0 -0
- /package/{components → dist/components}/tabs/components/item/index.d.ts.map +0 -0
- /package/{components → dist/components}/tabs/components/item/index.js +0 -0
- /package/{components → dist/components}/tabs/index.d.ts +0 -0
- /package/{components → dist/components}/tabs/index.d.ts.map +0 -0
- /package/{components → dist/components}/tabs/index.js +0 -0
- /package/{components → dist/components}/tabs/types.d.ts +0 -0
- /package/{components → dist/components}/tabs/types.d.ts.map +0 -0
- /package/{components → dist/components}/tabs/types.js +0 -0
- /package/{components → dist/components}/tag/component/index.d.ts +0 -0
- /package/{components → dist/components}/tag/component/index.d.ts.map +0 -0
- /package/{components → dist/components}/tag/component/index.js +0 -0
- /package/{components → dist/components}/tag/index.d.ts +0 -0
- /package/{components → dist/components}/tag/index.d.ts.map +0 -0
- /package/{components → dist/components}/tag/index.js +0 -0
- /package/{components → dist/components}/tag/types.d.ts +0 -0
- /package/{components → dist/components}/tag/types.d.ts.map +0 -0
- /package/{components → dist/components}/tag/types.js +0 -0
- /package/{components → dist/components}/types.d.ts +0 -0
- /package/{components → dist/components}/types.d.ts.map +0 -0
- /package/{components → dist/components}/types.js +0 -0
- /package/{hooks → dist/hooks}/index.d.ts +0 -0
- /package/{hooks → dist/hooks}/index.d.ts.map +0 -0
- /package/{hooks → dist/hooks}/index.js +0 -0
- /package/{hooks → dist/hooks}/useComponentOutsideClick.d.ts +0 -0
- /package/{hooks → dist/hooks}/useComponentOutsideClick.d.ts.map +0 -0
- /package/{hooks → dist/hooks}/useComponentOutsideClick.js +0 -0
- /package/{hooks → dist/hooks}/usePagination.d.ts +0 -0
- /package/{hooks → dist/hooks}/usePagination.d.ts.map +0 -0
- /package/{hooks → dist/hooks}/usePagination.js +0 -0
- /package/{index.d.ts → dist/index.d.ts} +0 -0
- /package/{index.d.ts.map → dist/index.d.ts.map} +0 -0
- /package/{index.js → dist/index.js} +0 -0
- /package/{tsconfig.tsbuildinfo → dist/tsconfig.tsbuildinfo} +0 -0
- /package/{utils → dist/utils}/dataAttributes.d.ts +0 -0
- /package/{utils → dist/utils}/dataAttributes.d.ts.map +0 -0
- /package/{utils → dist/utils}/dataAttributes.js +0 -0
- /package/{utils → dist/utils}/formValidation.d.ts +0 -0
- /package/{utils → dist/utils}/formValidation.d.ts.map +0 -0
- /package/{utils → dist/utils}/formValidation.js +0 -0
- /package/{utils → dist/utils}/index.d.ts +0 -0
- /package/{utils → dist/utils}/index.d.ts.map +0 -0
- /package/{utils → dist/utils}/index.js +0 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { ChangeEvent, useCallback } from "react";
|
|
2
|
+
|
|
3
|
+
import { generateGuid, getClassName, getValueOrDefault, } from "@bodynarf/utils";
|
|
4
|
+
|
|
5
|
+
import { ElementSize } from "@bbr/components";
|
|
6
|
+
import { getValidationValues } from "@bbr/utils";
|
|
7
|
+
|
|
8
|
+
import { TextProps } from "@bbr/components/text";
|
|
9
|
+
|
|
10
|
+
/** Textual input with describing label */
|
|
11
|
+
const TextWithLabel = ({
|
|
12
|
+
onValueChange, readonly, disabled, defaultValue, validationState,
|
|
13
|
+
name,
|
|
14
|
+
className, size, style, rounded, loading,
|
|
15
|
+
label, placeholder,
|
|
16
|
+
onBlur,
|
|
17
|
+
}: TextProps): JSX.Element => {
|
|
18
|
+
const onChange = useCallback(
|
|
19
|
+
(event: ChangeEvent<HTMLInputElement>) => onValueChange(event.target.value),
|
|
20
|
+
[onValueChange]
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
const id = name || generateGuid();
|
|
24
|
+
const elSizeClassName = "is-{0}".format(getValueOrDefault(size, ElementSize.Normal));
|
|
25
|
+
|
|
26
|
+
const [isValidationDefined, styleClassName, validationMessages] = getValidationValues(style, validationState);
|
|
27
|
+
|
|
28
|
+
const elClassName = getClassName([
|
|
29
|
+
className,
|
|
30
|
+
elSizeClassName,
|
|
31
|
+
rounded === true ? "is-rounded" : "",
|
|
32
|
+
styleClassName,
|
|
33
|
+
"input",
|
|
34
|
+
]);
|
|
35
|
+
|
|
36
|
+
const inputContainerClassName = getClassName([
|
|
37
|
+
"control",
|
|
38
|
+
loading === true ? "is-loading" : "",
|
|
39
|
+
]);
|
|
40
|
+
|
|
41
|
+
const labelClassName = getClassName([
|
|
42
|
+
"label",
|
|
43
|
+
!label!.horizontal ? elSizeClassName : "",
|
|
44
|
+
label!.className
|
|
45
|
+
]);
|
|
46
|
+
|
|
47
|
+
if (label!.horizontal) {
|
|
48
|
+
const labelContainerClassName = getClassName([
|
|
49
|
+
"field-label",
|
|
50
|
+
elSizeClassName,
|
|
51
|
+
label!.horizontalContainerClassName
|
|
52
|
+
]);
|
|
53
|
+
|
|
54
|
+
const fieldContainerClassName = getClassName([
|
|
55
|
+
"field-body",
|
|
56
|
+
label!.horizontalFieldContainerClassName
|
|
57
|
+
]);
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<div className="bbr-input field is-horizontal">
|
|
61
|
+
<div className={labelContainerClassName}>
|
|
62
|
+
<label
|
|
63
|
+
className={labelClassName}
|
|
64
|
+
htmlFor={id}
|
|
65
|
+
>
|
|
66
|
+
{label!.caption}
|
|
67
|
+
</label>
|
|
68
|
+
</div>
|
|
69
|
+
<div className={fieldContainerClassName}>
|
|
70
|
+
<div className="field">
|
|
71
|
+
<div className={inputContainerClassName}>
|
|
72
|
+
<input
|
|
73
|
+
type="text"
|
|
74
|
+
className={elClassName}
|
|
75
|
+
placeholder={placeholder}
|
|
76
|
+
readOnly={readonly}
|
|
77
|
+
disabled={disabled}
|
|
78
|
+
defaultValue={defaultValue}
|
|
79
|
+
onChange={onChange}
|
|
80
|
+
onBlur={onBlur}
|
|
81
|
+
name={id}
|
|
82
|
+
id={id}
|
|
83
|
+
/>
|
|
84
|
+
</div>
|
|
85
|
+
{isValidationDefined && validationMessages.length > 0 &&
|
|
86
|
+
<p className={`help m-help ${styleClassName}`}>{validationMessages.join("\n")}</p>
|
|
87
|
+
}
|
|
88
|
+
</div>
|
|
89
|
+
</div>
|
|
90
|
+
</div>
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return (
|
|
95
|
+
<div className="bbr-input field">
|
|
96
|
+
<label
|
|
97
|
+
className={labelClassName}
|
|
98
|
+
htmlFor={id}
|
|
99
|
+
>
|
|
100
|
+
{label!.caption}
|
|
101
|
+
</label>
|
|
102
|
+
<div className={inputContainerClassName}>
|
|
103
|
+
<input
|
|
104
|
+
type="text"
|
|
105
|
+
className={elClassName}
|
|
106
|
+
placeholder={placeholder}
|
|
107
|
+
readOnly={readonly}
|
|
108
|
+
disabled={disabled}
|
|
109
|
+
defaultValue={defaultValue}
|
|
110
|
+
onChange={onChange}
|
|
111
|
+
onBlur={onBlur}
|
|
112
|
+
name={id}
|
|
113
|
+
id={id}
|
|
114
|
+
/>
|
|
115
|
+
</div>
|
|
116
|
+
{isValidationDefined && validationMessages.length > 0 &&
|
|
117
|
+
<p className={`help m-help ${styleClassName}`}>{validationMessages.join("\n")}</p>
|
|
118
|
+
}
|
|
119
|
+
</div>
|
|
120
|
+
);
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
export default TextWithLabel;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { ChangeEvent, useCallback } from "react";
|
|
2
|
+
|
|
3
|
+
import { generateGuid, getClassName, getValueOrDefault } from "@bodynarf/utils";
|
|
4
|
+
|
|
5
|
+
import { ElementSize } from "@bbr/components";
|
|
6
|
+
import { getValidationValues } from "@bbr/utils";
|
|
7
|
+
|
|
8
|
+
import { TextProps } from "@bbr/components/text";
|
|
9
|
+
|
|
10
|
+
/** Textual input without describing label */
|
|
11
|
+
const TextWithoutLabel = ({
|
|
12
|
+
onValueChange, readonly, disabled, defaultValue, validationState,
|
|
13
|
+
name,
|
|
14
|
+
className, size, style, rounded, loading,
|
|
15
|
+
placeholder,
|
|
16
|
+
onBlur,
|
|
17
|
+
}: TextProps): JSX.Element => {
|
|
18
|
+
const onChange = useCallback(
|
|
19
|
+
(event: ChangeEvent<HTMLInputElement>) => onValueChange(event.target.value),
|
|
20
|
+
[onValueChange]
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
const [isValidationDefined, styleClassName, validationMessages] = getValidationValues(style, validationState);
|
|
24
|
+
|
|
25
|
+
const elClassName = getClassName([
|
|
26
|
+
className,
|
|
27
|
+
"is-{0}".format(getValueOrDefault(size, ElementSize.Normal)),
|
|
28
|
+
rounded === true ? "is-rounded" : "",
|
|
29
|
+
styleClassName,
|
|
30
|
+
"input",
|
|
31
|
+
]);
|
|
32
|
+
|
|
33
|
+
const containerClassName = getClassName([
|
|
34
|
+
"control",
|
|
35
|
+
"bbr-input",
|
|
36
|
+
loading === true ? "is-loading" : "",
|
|
37
|
+
]);
|
|
38
|
+
|
|
39
|
+
const id = name || generateGuid();
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<>
|
|
43
|
+
<div className={containerClassName}>
|
|
44
|
+
<input
|
|
45
|
+
className={elClassName}
|
|
46
|
+
type="text"
|
|
47
|
+
placeholder={placeholder}
|
|
48
|
+
readOnly={readonly}
|
|
49
|
+
disabled={disabled}
|
|
50
|
+
defaultValue={defaultValue}
|
|
51
|
+
onChange={onChange}
|
|
52
|
+
onBlur={onBlur}
|
|
53
|
+
name={id}
|
|
54
|
+
id={id}
|
|
55
|
+
/>
|
|
56
|
+
</div>
|
|
57
|
+
{isValidationDefined && validationMessages.length > 0 &&
|
|
58
|
+
<p className={`help m-help ${styleClassName}`}>{validationMessages.join("\n")}</p>
|
|
59
|
+
}
|
|
60
|
+
</>
|
|
61
|
+
);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export default TextWithoutLabel;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { BaseElementProps, ElementColor, ElementSize } from "@bbr/components";
|
|
2
|
+
|
|
3
|
+
import { InputLabel, ValidationState } from ".";
|
|
4
|
+
|
|
5
|
+
/** Base properties for input components */
|
|
6
|
+
export interface BaseInputElementProps<TValue> extends BaseElementProps {
|
|
7
|
+
/** Value change handler. Changed value must be stored outside of component */
|
|
8
|
+
onValueChange: (value?: TValue) => void;
|
|
9
|
+
|
|
10
|
+
/** Default value of input component*/
|
|
11
|
+
defaultValue?: TValue;
|
|
12
|
+
|
|
13
|
+
/** Input element placeholder */
|
|
14
|
+
placeholder?: string;
|
|
15
|
+
|
|
16
|
+
/** Is component borders are rounded */
|
|
17
|
+
rounded?: boolean;
|
|
18
|
+
|
|
19
|
+
/** Should be component disabled. Selecting is not allowed */
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
|
|
22
|
+
/** Should be component int read only mode. Selecting is allowed */
|
|
23
|
+
readonly?: boolean;
|
|
24
|
+
|
|
25
|
+
/** Component size */
|
|
26
|
+
size?: ElementSize;
|
|
27
|
+
|
|
28
|
+
/** Label configuration */
|
|
29
|
+
label?: InputLabel;
|
|
30
|
+
|
|
31
|
+
/** Displaying loading state of component as spinner in right end of component */
|
|
32
|
+
loading?: boolean;
|
|
33
|
+
|
|
34
|
+
/** Style. Colors the border */
|
|
35
|
+
style?: ElementColor;
|
|
36
|
+
|
|
37
|
+
/** Name of element. Required for form elements */
|
|
38
|
+
name?: string;
|
|
39
|
+
|
|
40
|
+
/** Current validation state */
|
|
41
|
+
validationState?: ValidationState;
|
|
42
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Input label configuration */
|
|
2
|
+
export interface InputLabel {
|
|
3
|
+
/** Label textual content to describe input requirements */
|
|
4
|
+
caption: string;
|
|
5
|
+
|
|
6
|
+
/** Should component be on same line with label */
|
|
7
|
+
horizontal: boolean;
|
|
8
|
+
|
|
9
|
+
/** Additional class names */
|
|
10
|
+
className?: string;
|
|
11
|
+
|
|
12
|
+
/** Class name for label parent container in horizontal mode */
|
|
13
|
+
horizontalContainerClassName?: string;
|
|
14
|
+
|
|
15
|
+
/** Class name for input parent container in horizontal mode */
|
|
16
|
+
horizontalFieldContainerClassName?: string;
|
|
17
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Input component value validation status */
|
|
2
|
+
export enum ValidationStatus {
|
|
3
|
+
/** Validation wasn"t been performed */
|
|
4
|
+
None = "none",
|
|
5
|
+
|
|
6
|
+
/** Value is valid */
|
|
7
|
+
Valid = "valid",
|
|
8
|
+
|
|
9
|
+
/** Value is invalid due some validator check */
|
|
10
|
+
Invalid = "invalid",
|
|
11
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { ChangeEvent, useCallback, useState } from "react";
|
|
2
|
+
|
|
3
|
+
import { generateGuid, getClassName } from "@bodynarf/utils";
|
|
4
|
+
|
|
5
|
+
import "./style.scss";
|
|
6
|
+
|
|
7
|
+
import Button from "@bbr/components/button";
|
|
8
|
+
|
|
9
|
+
import { SearchProps } from "@bbr/components/search";
|
|
10
|
+
|
|
11
|
+
/** Search component */
|
|
12
|
+
export default function Search({
|
|
13
|
+
searchType, onSearch, caption,
|
|
14
|
+
name, defaultValue,
|
|
15
|
+
size, isLoading, rounded, disabled,
|
|
16
|
+
}: SearchProps): JSX.Element {
|
|
17
|
+
const [elementName] = useState<string>(name || generateGuid());
|
|
18
|
+
const [searchValue, setSearchValue] = useState<string>(defaultValue || "");
|
|
19
|
+
|
|
20
|
+
const onChange = useCallback(
|
|
21
|
+
(event: ChangeEvent<HTMLInputElement>) => {
|
|
22
|
+
const elementValue: string = event.target.value;
|
|
23
|
+
|
|
24
|
+
if (searchType === "byTyping") {
|
|
25
|
+
onSearch(elementValue);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
setSearchValue(elementValue);
|
|
29
|
+
}, [onSearch, searchType]);
|
|
30
|
+
|
|
31
|
+
const onSearchButtonClick = useCallback(() => onSearch(searchValue), [onSearch, searchValue]);
|
|
32
|
+
|
|
33
|
+
const className: string = getClassName([
|
|
34
|
+
"bbr-search",
|
|
35
|
+
"control",
|
|
36
|
+
`is-${(size || "normal")}`,
|
|
37
|
+
isLoading === true ? "is-loading" : "",
|
|
38
|
+
searchType === "byButton" ? "is-expanded" : "",
|
|
39
|
+
]);
|
|
40
|
+
|
|
41
|
+
const inputClassName: string = getClassName([
|
|
42
|
+
"input",
|
|
43
|
+
"is-unselectable",
|
|
44
|
+
`is-${(size || "normal")}`,
|
|
45
|
+
rounded === true ? "is-rounded" : "",
|
|
46
|
+
]);
|
|
47
|
+
|
|
48
|
+
if (searchType === "byButton") {
|
|
49
|
+
return (
|
|
50
|
+
<div className="field has-addons">
|
|
51
|
+
<div className={className}>
|
|
52
|
+
<input
|
|
53
|
+
type="search"
|
|
54
|
+
name={elementName}
|
|
55
|
+
defaultValue={searchValue}
|
|
56
|
+
className={inputClassName}
|
|
57
|
+
disabled={disabled}
|
|
58
|
+
onChange={onChange}
|
|
59
|
+
placeholder={caption}
|
|
60
|
+
/>
|
|
61
|
+
</div>
|
|
62
|
+
<div className="control">
|
|
63
|
+
<Button
|
|
64
|
+
caption="Search"
|
|
65
|
+
type="info"
|
|
66
|
+
onClick={onSearchButtonClick}
|
|
67
|
+
isLoading={isLoading}
|
|
68
|
+
/>
|
|
69
|
+
</div>
|
|
70
|
+
</div>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
return (
|
|
75
|
+
<div className={className}>
|
|
76
|
+
<input
|
|
77
|
+
type="search"
|
|
78
|
+
name={elementName}
|
|
79
|
+
defaultValue={searchValue}
|
|
80
|
+
className={inputClassName}
|
|
81
|
+
disabled={disabled}
|
|
82
|
+
onChange={onChange}
|
|
83
|
+
placeholder={caption}
|
|
84
|
+
/>
|
|
85
|
+
</div>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
.bbr-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
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ElementSize } from "@bbr/components";
|
|
2
|
+
|
|
3
|
+
/** Search component props type */
|
|
4
|
+
export interface SearchProps {
|
|
5
|
+
/**
|
|
6
|
+
* Search type: by typing, starts from minimum characters to search
|
|
7
|
+
* or by clicking on button next to search bar.
|
|
8
|
+
* Default `is byTyping`
|
|
9
|
+
*/
|
|
10
|
+
searchType: "byTyping" | "byButton";
|
|
11
|
+
|
|
12
|
+
/** Search caption */
|
|
13
|
+
caption: string;
|
|
14
|
+
|
|
15
|
+
/** Search handler */
|
|
16
|
+
onSearch: (searchPattern: string) => void;
|
|
17
|
+
|
|
18
|
+
/** Initial search value */
|
|
19
|
+
defaultValue?: string;
|
|
20
|
+
|
|
21
|
+
/** Control name. If empty - will be replaced by random guid */
|
|
22
|
+
name?: string;
|
|
23
|
+
|
|
24
|
+
/** Size of search bar */
|
|
25
|
+
size?: ElementSize;
|
|
26
|
+
|
|
27
|
+
/** Should search bar be rounded */
|
|
28
|
+
rounded?: boolean;
|
|
29
|
+
|
|
30
|
+
/** Is search bar disabled */
|
|
31
|
+
disabled?: boolean;
|
|
32
|
+
|
|
33
|
+
/** Should loading icon be displayed in search bar */
|
|
34
|
+
isLoading?: boolean;
|
|
35
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { useCallback, useState, MouseEvent, useEffect, useRef } from "react";
|
|
2
|
+
|
|
3
|
+
import { getClassName, isNullOrEmpty, isNullOrUndefined } from "@bodynarf/utils";
|
|
4
|
+
|
|
5
|
+
import "./style.scss";
|
|
6
|
+
|
|
7
|
+
import { BaseElementProps, ElementSize } from "@bbr/components";
|
|
8
|
+
import { mapDataAttributes } from "@bbr/utils";
|
|
9
|
+
|
|
10
|
+
import { TabItem, TabsPosition, TabsStyle } from "@bbr/components/tabs";
|
|
11
|
+
import TabItemComponent from "@bbr/components/tabs/components/item";
|
|
12
|
+
|
|
13
|
+
/** Tabs component props type */
|
|
14
|
+
export interface TabsProps extends BaseElementProps {
|
|
15
|
+
/** Tabs */
|
|
16
|
+
items: Array<TabItem>;
|
|
17
|
+
|
|
18
|
+
/** Handler of changing current active item */
|
|
19
|
+
onActiveItemChange: (item: TabItem) => void;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Active item by default.
|
|
23
|
+
* If not set - first item will be active
|
|
24
|
+
*/
|
|
25
|
+
defaultActive?: TabItem;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Component size.
|
|
29
|
+
* Default is `normal`
|
|
30
|
+
*/
|
|
31
|
+
size?: ElementSize;
|
|
32
|
+
|
|
33
|
+
/** Component position */
|
|
34
|
+
position?: TabsPosition;
|
|
35
|
+
|
|
36
|
+
/** Component style */
|
|
37
|
+
style?: TabsStyle;
|
|
38
|
+
|
|
39
|
+
/** Is component tabs should take all width of parent */
|
|
40
|
+
fullWidth?: boolean;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Tabs panel
|
|
45
|
+
* @throws Items are empty
|
|
46
|
+
*/
|
|
47
|
+
const Tabs = ({
|
|
48
|
+
items, onActiveItemChange,
|
|
49
|
+
defaultActive,
|
|
50
|
+
size, position, style, fullWidth,
|
|
51
|
+
|
|
52
|
+
className, title, data,
|
|
53
|
+
}: TabsProps): JSX.Element => {
|
|
54
|
+
if (items.length === 0) {
|
|
55
|
+
throw new Error("Invalid configuration. Tab items must be defined");
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const [activeItem, setActiveItem] = useState<TabItem>(defaultActive ?? items[0]);
|
|
59
|
+
const isFirstRun = useRef(true);
|
|
60
|
+
|
|
61
|
+
const onTabsClick = useCallback(
|
|
62
|
+
(container: MouseEvent<HTMLElement>) => {
|
|
63
|
+
const closestTab = (container.target as HTMLElement).closest(".bbr-tabs__tab");
|
|
64
|
+
|
|
65
|
+
if (isNullOrUndefined(closestTab)) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const itemId = closestTab!.attributes.getNamedItem("data-item-id")?.value ?? "";
|
|
70
|
+
|
|
71
|
+
if (isNullOrEmpty(itemId)) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const item = items.find(({ id }) => id === itemId);
|
|
76
|
+
|
|
77
|
+
if (isNullOrUndefined(item) || item === activeItem) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
setActiveItem(item!);
|
|
82
|
+
},
|
|
83
|
+
[activeItem, items]
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
useEffect(
|
|
87
|
+
() => {
|
|
88
|
+
if (isFirstRun.current) {
|
|
89
|
+
isFirstRun.current = false;
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
onActiveItemChange(activeItem);
|
|
94
|
+
},
|
|
95
|
+
[activeItem, onActiveItemChange]
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
const elClassName = getClassName([
|
|
99
|
+
"bbr-tabs",
|
|
100
|
+
"tabs",
|
|
101
|
+
position ?? TabsPosition.left,
|
|
102
|
+
getSizeClassName(size, [ElementSize.Normal]),
|
|
103
|
+
style ?? TabsStyle.default,
|
|
104
|
+
fullWidth === true ? "is-fullwidth" : "",
|
|
105
|
+
className,
|
|
106
|
+
]);
|
|
107
|
+
|
|
108
|
+
const dataAttributes = isNullOrUndefined(data)
|
|
109
|
+
? undefined
|
|
110
|
+
: mapDataAttributes(data!);
|
|
111
|
+
|
|
112
|
+
return (
|
|
113
|
+
<nav
|
|
114
|
+
className={elClassName}
|
|
115
|
+
onClick={onTabsClick}
|
|
116
|
+
title={title}
|
|
117
|
+
{...dataAttributes}
|
|
118
|
+
>
|
|
119
|
+
<ul>
|
|
120
|
+
{items.map(item =>
|
|
121
|
+
<TabItemComponent
|
|
122
|
+
key={item.id}
|
|
123
|
+
item={item}
|
|
124
|
+
activeItem={activeItem.id}
|
|
125
|
+
/>
|
|
126
|
+
)}
|
|
127
|
+
</ul>
|
|
128
|
+
</nav>
|
|
129
|
+
);
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
export default Tabs;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Get class name for specified size and constraints
|
|
136
|
+
* @param size Component size
|
|
137
|
+
* @param notAllowedSizes Sizes that not applicable to component
|
|
138
|
+
* @returns Class name for react element
|
|
139
|
+
*/
|
|
140
|
+
const getSizeClassName = (size?: ElementSize, notAllowedSizes?: Array<ElementSize>): string => {
|
|
141
|
+
notAllowedSizes ??= [];
|
|
142
|
+
if (isNullOrUndefined(size) || notAllowedSizes.includes(size!)) {
|
|
143
|
+
return "";
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return `is-${size}`;
|
|
147
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { getClassName, isNullOrUndefined } from "@bodynarf/utils";
|
|
2
|
+
|
|
3
|
+
import Icon from "@bbr/components/icon";
|
|
4
|
+
|
|
5
|
+
import { TabItem as Item } from "@bbr/components/tabs";
|
|
6
|
+
|
|
7
|
+
/** Tabs panel single tab item component props type */
|
|
8
|
+
export interface TabItemProps {
|
|
9
|
+
/** Tab item */
|
|
10
|
+
item: Item;
|
|
11
|
+
|
|
12
|
+
/** Active item identifier */
|
|
13
|
+
activeItem: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** Tabs panel single tab item component */
|
|
17
|
+
const TabItem = ({
|
|
18
|
+
item, activeItem
|
|
19
|
+
}: TabItemProps): JSX.Element => {
|
|
20
|
+
if (!isNullOrUndefined(item.icon)) {
|
|
21
|
+
return <TabItemWithIcon item={item} activeItem={activeItem} />;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const className = getClassName([
|
|
25
|
+
"bbr-tabs__tab",
|
|
26
|
+
activeItem === item.id ? "is-active" : undefined,
|
|
27
|
+
]);
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<li
|
|
31
|
+
key={item.id}
|
|
32
|
+
className={className}
|
|
33
|
+
data-item-id={item.id}
|
|
34
|
+
>
|
|
35
|
+
<a>
|
|
36
|
+
{item.caption}
|
|
37
|
+
</a>
|
|
38
|
+
</li>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export default TabItem;
|
|
43
|
+
|
|
44
|
+
/** Tabs panel single tab item with icon component */
|
|
45
|
+
const TabItemWithIcon = ({
|
|
46
|
+
item, activeItem
|
|
47
|
+
}: TabItemProps): JSX.Element => {
|
|
48
|
+
const iconConfig = item.icon!;
|
|
49
|
+
|
|
50
|
+
const className = getClassName([
|
|
51
|
+
"bbr-tabs__tab",
|
|
52
|
+
activeItem === item.id ? "is-active" : undefined,
|
|
53
|
+
]);
|
|
54
|
+
|
|
55
|
+
if (iconConfig.position === "left") {
|
|
56
|
+
return (
|
|
57
|
+
<li
|
|
58
|
+
key={item.id}
|
|
59
|
+
className={className}
|
|
60
|
+
data-item-id={item.id}
|
|
61
|
+
>
|
|
62
|
+
<a>
|
|
63
|
+
<Icon {...iconConfig} />
|
|
64
|
+
<span>
|
|
65
|
+
{item.caption}
|
|
66
|
+
</span>
|
|
67
|
+
</a>
|
|
68
|
+
</li>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<li
|
|
74
|
+
key={item.id}
|
|
75
|
+
className={className}
|
|
76
|
+
data-item-id={item.id}
|
|
77
|
+
>
|
|
78
|
+
<a>
|
|
79
|
+
<span>
|
|
80
|
+
{item.caption}
|
|
81
|
+
</span>
|
|
82
|
+
<Icon {...iconConfig} />
|
|
83
|
+
</a>
|
|
84
|
+
</li>
|
|
85
|
+
);
|
|
86
|
+
};
|