@konturio/ui-kit
Advanced tools
Comparing version 3.0.0-alpha.39 to 3.0.0-alpha.40
{ | ||
"name": "@konturio/ui-kit", | ||
"version": "3.0.0-alpha.39", | ||
"version": "3.0.0-alpha.40", | ||
"repository": { | ||
@@ -28,3 +28,3 @@ "type": "git", | ||
}, | ||
"gitHead": "9f4b36103533c97acbf7c5d43b1af5d058f85683" | ||
"gitHead": "d134aa07ba3bdb6e71dca5903b74b7093c512b11" | ||
} |
/// <reference types="react" /> | ||
import { ButtonProps } from '../Button'; | ||
export declare function ActionsBar({ children }: React.PropsWithChildren<unknown>): JSX.Element; | ||
export declare function ActionsBarBTN({ children, className, ...props }: React.PropsWithChildren<ButtonProps>): JSX.Element; | ||
export declare function ActionsBarBTN({ children, className, ...props }: ButtonProps): JSX.Element; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,2 +0,2 @@ | ||
import { ReactChild } from 'react'; | ||
import { ReactChild, ReactNode } from 'react'; | ||
export interface ButtonProps { | ||
@@ -7,3 +7,3 @@ onClick?: React.MouseEventHandler<HTMLButtonElement>; | ||
transparent?: boolean; | ||
variant?: 'primary' | 'invert-outline' | 'invert'; | ||
variant?: 'primary' | 'invert-outline' | 'invert' | 'radio'; | ||
size?: 'medium' | 'small'; | ||
@@ -15,6 +15,5 @@ id?: string; | ||
iconAfter?: ReactChild | null; | ||
children?: ReactNode; | ||
} | ||
export declare const Button: import("react").ForwardRefExoticComponent<ButtonProps & { | ||
children?: import("react").ReactNode; | ||
} & import("react").RefAttributes<HTMLButtonElement>>; | ||
export declare const Button: import("react").ForwardRefExoticComponent<ButtonProps & import("react").RefAttributes<HTMLButtonElement>>; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,13 +0,15 @@ | ||
import { ReactElement } from 'react'; | ||
import { ButtonProps } from '../Button'; | ||
import { ReactNode } from 'react'; | ||
export interface ButtonGroupProps { | ||
current?: string; | ||
onChange: (buttonId: string) => void; | ||
children: ReactElement<ButtonProps>[]; | ||
onChange?: (buttonId: string) => void; | ||
children: ReactNode; | ||
classes?: { | ||
btnContainer?: string; | ||
groupContainer?: string; | ||
label?: string; | ||
}; | ||
renderLabel?: JSX.Element | string; | ||
borderWrap?: boolean; | ||
} | ||
export declare function ButtonGroup({ current, children, onChange, classes }: ButtonGroupProps): JSX.Element; | ||
export declare function ButtonGroup({ current, children, onChange, classes, renderLabel, borderWrap, }: ButtonGroupProps): JSX.Element; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,8 +0,8 @@ | ||
import { jsx as _jsx } from "react/jsx-runtime"; | ||
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; | ||
import React, { Children, isValidElement, useMemo, useState } from 'react'; | ||
import s from './style.module.css'; | ||
import clsx from 'clsx'; | ||
export function ButtonGroup({ current, children, onChange, classes }) { | ||
export function ButtonGroup({ current, children, onChange, classes, renderLabel, borderWrap = true, }) { | ||
const buttonElements = Children.toArray(children).filter((button) => isValidElement(button)); | ||
const [activeBtn, setActiveBtn] = useState(undefined); | ||
const [activeBtn, setActiveBtn] = useState(current); | ||
const buttons = useMemo(() => { | ||
@@ -14,3 +14,3 @@ return buttonElements.map((button) => { | ||
element: button, | ||
isActive: ((_a = button === null || button === void 0 ? void 0 : button.props) === null || _a === void 0 ? void 0 : _a.id) === activeBtn, | ||
isActive: ((_a = button === null || button === void 0 ? void 0 : button.props) === null || _a === void 0 ? void 0 : _a.id) ? button.props.id === activeBtn : false, | ||
id: (_b = button === null || button === void 0 ? void 0 : button.props) === null || _b === void 0 ? void 0 : _b.id, | ||
@@ -23,3 +23,4 @@ }); | ||
setActiveBtn(btnId); | ||
onChange(btnId); | ||
if (onChange) | ||
onChange(btnId); | ||
} | ||
@@ -30,5 +31,7 @@ else { | ||
}; | ||
return (_jsx("div", Object.assign({ className: clsx(s.groupContainer, classes === null || classes === void 0 ? void 0 : classes.groupContainer) }, { children: buttons.map((button) => (_jsx("div", Object.assign({ className: clsx(classes === null || classes === void 0 ? void 0 : classes.btnContainer, s.button, button.isActive && s.activeBtn, button.isActive && 'activeBtn'), onClick: () => { | ||
onBtnClick(button.id); | ||
} }, { children: React.cloneElement(button.element, button.props) }), button.id))) }))); | ||
return (_jsxs("div", Object.assign({ className: s.root }, { children: [renderLabel && _jsx("div", Object.assign({ className: clsx(s.label, classes === null || classes === void 0 ? void 0 : classes.label) }, { children: renderLabel })), _jsx("div", Object.assign({ className: clsx(s.groupContainer, borderWrap && s.defaultBorderWrap, classes === null || classes === void 0 ? void 0 : classes.groupContainer) }, { children: buttons.map((button) => (_jsx("div", Object.assign({ className: clsx(classes === null || classes === void 0 ? void 0 : classes.btnContainer, s.button, button.isActive && s.activeBtn), onClick: () => { | ||
if (button.id) { | ||
onBtnClick(button.id); | ||
} | ||
} }, { children: React.cloneElement(button.element, Object.assign(Object.assign({}, button.props), { active: button.isActive })) }), button.id))) }))] }))); | ||
} |
@@ -13,2 +13,3 @@ var __rest = (this && this.__rest) || function (s, e) { | ||
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; | ||
import { Finish16 } from '@konturio/default-icons'; | ||
import { LineItem } from '../LineItem'; | ||
@@ -18,3 +19,3 @@ import s from './style.module.css'; | ||
var { name, label, className = '', block = true, id } = _a, native = __rest(_a, ["name", "label", "className", "block", "id"]); | ||
return (_jsxs(LineItem, Object.assign({ id: id, label: label, className: className, block: block, cursor: "pointer" }, { children: [_jsx("input", Object.assign({ id: id, name: name, type: "checkbox", className: s.checkbox }, native)), _jsx("div", Object.assign({ className: s.icon }, { children: _jsx("svg", Object.assign({ width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: _jsx("path", { d: "M3 9L6.5 12.5L14 5", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round" }) })) }))] }))); | ||
return (_jsxs(LineItem, Object.assign({ id: id, label: label, className: className, block: block, cursor: "pointer" }, { children: [_jsx("input", Object.assign({ id: id, name: name, type: "checkbox", className: s.checkbox }, native)), _jsx("div", Object.assign({ className: s.icon }, { children: _jsx(Finish16, {}) }))] }))); | ||
} |
@@ -9,3 +9,3 @@ import React from 'react'; | ||
showTopPlaceholder?: boolean; | ||
renderLabel?: JSX.Element; | ||
renderLabel?: JSX.Element | string; | ||
classes?: { | ||
@@ -12,0 +12,0 @@ inputBox?: string; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
381951
206
8101