@konturio/ui-kit
Advanced tools
Comparing version 3.0.0-alpha.48 to 3.0.0-alpha.49
{ | ||
"name": "@konturio/ui-kit", | ||
"version": "3.0.0-alpha.48", | ||
"version": "3.0.0-alpha.49", | ||
"repository": { | ||
@@ -32,3 +32,3 @@ "type": "git", | ||
}, | ||
"gitHead": "ca65f71ce06ac3cca9d1a378ffe5a056c9bc676d" | ||
"gitHead": "92ff76c3a20ed5b468f0d1eb42a111c24f8c9fde" | ||
} |
@@ -22,4 +22,5 @@ import React from 'react'; | ||
type: 'classic' | 'inline'; | ||
reset: () => void; | ||
} | ||
export declare const SelectButton: ForwardRefComponent<"div", SelectButtonProps>; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -13,8 +13,8 @@ var __rest = (this && this.__rest) || function (s, e) { | ||
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; | ||
import React from 'react'; | ||
import { ChevronDown16, ChevronUp16 } from '@konturio/default-icons'; | ||
import React, { useCallback } from 'react'; | ||
import { ChevronDown16, ChevronUp16, Close16 } from '@konturio/default-icons'; | ||
import cn from 'clsx'; | ||
import style from './style.module.css'; | ||
export const SelectButton = React.forwardRef((_a, ref) => { | ||
var { children = 'Select', value, open = false, label, className, classes, toggleProps, labelProps, disabled, error, type } = _a, props = __rest(_a, ["children", "value", "open", "label", "className", "classes", "toggleProps", "labelProps", "disabled", "error", "type"]); | ||
var { children = 'Select', value, open = false, label, className, classes, toggleProps, labelProps, disabled, error, type, reset } = _a, props = __rest(_a, ["children", "value", "open", "label", "className", "classes", "toggleProps", "labelProps", "disabled", "error", "type", "reset"]); | ||
const dynamicClasses = cn({ | ||
@@ -27,4 +27,9 @@ [style.root]: true, | ||
}); | ||
return (_jsxs("div", Object.assign({ className: dynamicClasses }, props, { ref: ref }, { children: [label && (_jsx("label", Object.assign({ className: cn(style.label, classes === null || classes === void 0 ? void 0 : classes.label) }, labelProps, { children: label }))), _jsxs("button", Object.assign({ disabled: disabled, type: "button", "aria-label": "toggle menu" }, toggleProps, { className: cn(style.selectBox, classes === null || classes === void 0 ? void 0 : classes.selectBox) }, { children: [_jsx("div", Object.assign({ className: cn(style.placeholder, classes === null || classes === void 0 ? void 0 : classes.placeholder) }, { children: (value === null || value === void 0 ? void 0 : value.title) || children })), _jsx("div", Object.assign({ className: style.openToggle }, { children: open ? _jsx(ChevronUp16, {}) : _jsx(ChevronDown16, {}) }))] })), error && typeof error === 'string' ? (_jsx("div", Object.assign({ className: cn(style.errorMessage, classes === null || classes === void 0 ? void 0 : classes.error) }, { children: error }))) : null] }))); | ||
const onReset = useCallback((e) => { | ||
reset(); | ||
e.stopPropagation(); | ||
}, [reset]); | ||
const title = value === null || value === void 0 ? void 0 : value.title; | ||
return (_jsxs("div", Object.assign({ className: dynamicClasses }, props, { ref: ref }, { children: [label && (_jsx("label", Object.assign({ className: cn(style.label, classes === null || classes === void 0 ? void 0 : classes.label) }, labelProps, { children: label }))), _jsxs("button", Object.assign({ disabled: disabled, type: "button", "aria-label": "toggle menu" }, toggleProps, { className: cn(style.selectBox, classes === null || classes === void 0 ? void 0 : classes.selectBox) }, { children: [_jsx("div", Object.assign({ className: cn(style.placeholder, !title && style.noValue, classes === null || classes === void 0 ? void 0 : classes.placeholder) }, { children: title || children })), _jsx("div", Object.assign({ className: style.openToggle }, { children: title ? (_jsx(Close16, { className: style.closeIcon, onClick: onReset })) : open ? (_jsx(ChevronUp16, {})) : (_jsx(ChevronDown16, {})) }))] })), error && typeof error === 'string' ? (_jsx("div", Object.assign({ className: cn(style.errorMessage, classes === null || classes === void 0 ? void 0 : classes.error) }, { children: error }))) : null] }))); | ||
}); | ||
SelectButton.displayName = 'SelectButton'; |
@@ -21,3 +21,3 @@ var __rest = (this && this.__rest) || function (s, e) { | ||
var { children, items, itemToString, label, placeholder, classes, className, disabled, error, type = 'classic', onChange: onSelectedItemChange } = _a, props = __rest(_a, ["children", "items", "itemToString", "label", "placeholder", "classes", "className", "disabled", "error", "type", "onChange"]); | ||
const { isOpen, selectedItem, getToggleButtonProps, getLabelProps, getMenuProps, highlightedIndex, getItemProps } = useSelect({ | ||
const { isOpen, selectedItem, reset, getToggleButtonProps, getLabelProps, getMenuProps, highlightedIndex, getItemProps, } = useSelect({ | ||
items, | ||
@@ -30,5 +30,5 @@ itemToString, | ||
className, | ||
}) }, props, { children: [_jsx(SelectButton, Object.assign({ value: selectedItem, labelProps: getLabelProps(), toggleProps: getToggleButtonProps(), label: label, disabled: disabled, open: isOpen, error: error, type: type }, { children: children })), _jsx("ul", Object.assign({}, getMenuProps(), { className: cn({ [style.menu]: true, [(classes === null || classes === void 0 ? void 0 : classes.menu) || '']: classes === null || classes === void 0 ? void 0 : classes.menu }) }, { children: isOpen && | ||
}) }, props, { children: [_jsx(SelectButton, Object.assign({ value: selectedItem, labelProps: getLabelProps(), toggleProps: getToggleButtonProps(), label: label, disabled: disabled, open: isOpen, error: error, type: type, reset: reset }, { children: children })), _jsx("ul", Object.assign({}, getMenuProps(), { className: cn({ [style.menu]: true, [(classes === null || classes === void 0 ? void 0 : classes.menu) || '']: classes === null || classes === void 0 ? void 0 : classes.menu }) }, { children: isOpen && | ||
items.map((item, index) => (_jsx(SelectItem, { item: item, itemProps: getItemProps({ item, index }), className: classes === null || classes === void 0 ? void 0 : classes.menuItem, highlighted: highlightedIndex === index, selected: selectedItem === item }, `${item.value}${index}`))) }))] }))); | ||
}); | ||
Select.displayName = 'Select'; |
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
338569
5956