@snack-uikit/button
Advanced tools
Comparing version 0.14.1 to 0.15.0
@@ -6,2 +6,13 @@ # Change Log | ||
# 0.15.0 (2023-12-14) | ||
### BREAKING CHANGES | ||
* **FF-3729:** replace enum with unions ([910db4a](https://github.com/cloud-ru-tech/snack-uikit/commit/910db4aa8231ccbc58e538e5c5c1f461b1dec275)) | ||
## 0.14.1 (2023-12-06) | ||
@@ -8,0 +19,0 @@ |
/// <reference types="react" /> | ||
import { WithSupportProps } from '@snack-uikit/utils'; | ||
import { HtmlType, Target } from '../../constants'; | ||
import { CommonButtonProps } from '../../types'; | ||
import { Size } from './constants'; | ||
import { Size } from './types'; | ||
export type ButtonElevatedProps = WithSupportProps<Omit<CommonButtonProps, 'iconPosition' | 'label' | 'appearance' | 'labelClassName' | 'size'> & Required<Pick<CommonButtonProps, 'icon'>> & { | ||
@@ -15,6 +14,2 @@ /** Размер */ | ||
size?: Size | undefined; | ||
} & import("react").RefAttributes<HTMLAnchorElement | HTMLButtonElement>> & { | ||
types: typeof HtmlType; | ||
sizes: typeof Size; | ||
targets: typeof Target; | ||
}; | ||
} & import("react").RefAttributes<HTMLAnchorElement | HTMLButtonElement>>; |
@@ -16,14 +16,10 @@ var __rest = (this && this.__rest) || function (s, e) { | ||
import { extractSupportProps } from '@snack-uikit/utils'; | ||
import { HtmlType, Target } from '../../constants'; | ||
import { HTML_TYPE, TARGET } from '../../constants'; | ||
import { ButtonPrivate } from '../../helperComponents'; | ||
import { extractCommonButtonProps } from '../../utils'; | ||
import { Size } from './constants'; | ||
import { SIZE } from './constants'; | ||
import styles from './styles.module.css'; | ||
const ForwardedButtonElevated = forwardRef((_a, ref) => { | ||
var { className, size = Size.S, target = Target.Blank, type = HtmlType.Button, tabIndex } = _a, rest = __rest(_a, ["className", "size", "target", "type", "tabIndex"]); | ||
export const ButtonElevated = forwardRef((_a, ref) => { | ||
var { className, size = SIZE.S, target = TARGET.Blank, type = HTML_TYPE.Button, tabIndex } = _a, rest = __rest(_a, ["className", "size", "target", "type", "tabIndex"]); | ||
return (_jsx(ButtonPrivate, Object.assign({}, extractSupportProps(rest), extractCommonButtonProps(rest), { className: cn(styles.button, className), iconClassName: styles.icon, labelClassName: styles.label, size: size, target: target, type: type, tabIndex: tabIndex, ref: ref }))); | ||
}); | ||
export const ButtonElevated = ForwardedButtonElevated; | ||
ButtonElevated.sizes = Size; | ||
ButtonElevated.types = HtmlType; | ||
ButtonElevated.targets = Target; |
@@ -1,6 +0,6 @@ | ||
export declare enum Size { | ||
Xs = "xs", | ||
S = "s", | ||
M = "m", | ||
L = "l" | ||
} | ||
export declare const SIZE: { | ||
readonly Xs: "xs"; | ||
readonly S: "s"; | ||
readonly M: "m"; | ||
readonly L: "l"; | ||
}; |
@@ -1,7 +0,6 @@ | ||
export var Size; | ||
(function (Size) { | ||
Size["Xs"] = "xs"; | ||
Size["S"] = "s"; | ||
Size["M"] = "m"; | ||
Size["L"] = "l"; | ||
})(Size || (Size = {})); | ||
export const SIZE = { | ||
Xs: 'xs', | ||
S: 's', | ||
M: 'm', | ||
L: 'l', | ||
}; |
/// <reference types="react" /> | ||
import { WithSupportProps } from '@snack-uikit/utils'; | ||
import { Appearance, HtmlType, SizeSL, Target } from '../../constants'; | ||
import { CommonButtonProps } from '../../types'; | ||
import { CommonButtonProps, SizeSL } from '../../types'; | ||
export type ButtonFilledProps = WithSupportProps<Omit<CommonButtonProps, 'iconPosition' | 'size'> & { | ||
@@ -12,7 +11,2 @@ size?: SizeSL; | ||
size?: SizeSL | undefined; | ||
} & import("react").RefAttributes<HTMLAnchorElement | HTMLButtonElement>> & { | ||
types: typeof HtmlType; | ||
sizes: typeof SizeSL; | ||
appearances: typeof Appearance; | ||
targets: typeof Target; | ||
}; | ||
} & import("react").RefAttributes<HTMLAnchorElement | HTMLButtonElement>>; |
@@ -16,14 +16,9 @@ var __rest = (this && this.__rest) || function (s, e) { | ||
import { extractSupportProps } from '@snack-uikit/utils'; | ||
import { Appearance, HtmlType, SizeSL, Target } from '../../constants'; | ||
import { APPEARANCE, HTML_TYPE, SIZE_S_L, TARGET } from '../../constants'; | ||
import { ButtonPrivate } from '../../helperComponents'; | ||
import { extractCommonButtonProps } from '../../utils'; | ||
import styles from './styles.module.css'; | ||
const ForwardedButtonFilled = forwardRef((_a, ref) => { | ||
var { className, size = SizeSL.S, target = Target.Blank, type = HtmlType.Button, appearance = Appearance.Primary, tabIndex } = _a, rest = __rest(_a, ["className", "size", "target", "type", "appearance", "tabIndex"]); | ||
export const ButtonFilled = forwardRef((_a, ref) => { | ||
var { className, size = SIZE_S_L.S, target = TARGET.Blank, type = HTML_TYPE.Button, appearance = APPEARANCE.Primary, tabIndex } = _a, rest = __rest(_a, ["className", "size", "target", "type", "appearance", "tabIndex"]); | ||
return (_jsx(ButtonPrivate, Object.assign({}, extractSupportProps(rest), extractCommonButtonProps(rest), { className: cn(styles.button, className), iconClassName: styles.icon, labelClassName: styles.label, size: size, target: target, type: type, appearance: appearance, tabIndex: tabIndex, ref: ref }))); | ||
}); | ||
export const ButtonFilled = ForwardedButtonFilled; | ||
ButtonFilled.sizes = SizeSL; | ||
ButtonFilled.types = HtmlType; | ||
ButtonFilled.appearances = Appearance; | ||
ButtonFilled.targets = Target; |
/// <reference types="react" /> | ||
import { WithSupportProps } from '@snack-uikit/utils'; | ||
import { Appearance, HtmlType, IconPosition, SizeXsM, Target } from '../../constants'; | ||
import { CommonButtonProps, CounterButtonProps } from '../../types'; | ||
import { CommonButtonProps, CounterButtonProps, SizeXsM } from '../../types'; | ||
export type ButtonFunctionProps = WithSupportProps<Omit<CommonButtonProps, 'size'> & { | ||
@@ -12,8 +11,2 @@ size?: SizeXsM; | ||
size?: SizeXsM | undefined; | ||
} & CounterButtonProps & import("react").RefAttributes<HTMLAnchorElement | HTMLButtonElement>> & { | ||
types: typeof HtmlType; | ||
iconPositions: typeof IconPosition; | ||
sizes: typeof SizeXsM; | ||
appearances: typeof Appearance; | ||
targets: typeof Target; | ||
}; | ||
} & CounterButtonProps & import("react").RefAttributes<HTMLAnchorElement | HTMLButtonElement>>; |
@@ -16,15 +16,9 @@ var __rest = (this && this.__rest) || function (s, e) { | ||
import { extractSupportProps } from '@snack-uikit/utils'; | ||
import { Appearance, HtmlType, IconPosition, SizeXsM, Target } from '../../constants'; | ||
import { APPEARANCE, HTML_TYPE, ICON_POSITION, SIZE_XS_M, TARGET } from '../../constants'; | ||
import { ButtonPrivate } from '../../helperComponents'; | ||
import { extractCommonButtonProps, extractCounterButtonProps } from '../../utils'; | ||
import styles from './styles.module.css'; | ||
const ForwardedButtonFunction = forwardRef((_a, ref) => { | ||
var { className, iconPosition = IconPosition.After, size = SizeXsM.S, target = Target.Blank, type = HtmlType.Button, appearance = Appearance.Neutral, tabIndex } = _a, rest = __rest(_a, ["className", "iconPosition", "size", "target", "type", "appearance", "tabIndex"]); | ||
export const ButtonFunction = forwardRef((_a, ref) => { | ||
var { className, iconPosition = ICON_POSITION.After, size = SIZE_XS_M.S, target = TARGET.Blank, type = HTML_TYPE.Button, appearance = APPEARANCE.Neutral, tabIndex } = _a, rest = __rest(_a, ["className", "iconPosition", "size", "target", "type", "appearance", "tabIndex"]); | ||
return (_jsx(ButtonPrivate, Object.assign({}, extractSupportProps(rest), extractCounterButtonProps(rest), extractCommonButtonProps(rest), { className: cn(styles.button, className), iconClassName: styles.icon, iconPosition: iconPosition, labelClassName: styles.label, size: size, target: target, type: type, appearance: appearance, tabIndex: tabIndex, ref: ref }))); | ||
}); | ||
export const ButtonFunction = ForwardedButtonFunction; | ||
ButtonFunction.iconPositions = IconPosition; | ||
ButtonFunction.sizes = SizeXsM; | ||
ButtonFunction.types = HtmlType; | ||
ButtonFunction.appearances = Appearance; | ||
ButtonFunction.targets = Target; |
/// <reference types="react" /> | ||
import { WithSupportProps } from '@snack-uikit/utils'; | ||
import { Appearance, HtmlType, SizeSL, Target } from '../../constants'; | ||
import { CommonButtonProps } from '../../types'; | ||
import { CommonButtonProps, SizeSL } from '../../types'; | ||
export type ButtonOutlineProps = WithSupportProps<Omit<CommonButtonProps, 'iconPosition' | 'size'> & { | ||
@@ -12,7 +11,2 @@ size?: SizeSL; | ||
size?: SizeSL | undefined; | ||
} & import("react").RefAttributes<HTMLAnchorElement | HTMLButtonElement>> & { | ||
types: typeof HtmlType; | ||
sizes: typeof SizeSL; | ||
appearances: typeof Appearance; | ||
targets: typeof Target; | ||
}; | ||
} & import("react").RefAttributes<HTMLAnchorElement | HTMLButtonElement>>; |
@@ -16,14 +16,9 @@ var __rest = (this && this.__rest) || function (s, e) { | ||
import { extractSupportProps } from '@snack-uikit/utils'; | ||
import { Appearance, HtmlType, SizeSL, Target } from '../../constants'; | ||
import { APPEARANCE, HTML_TYPE, SIZE_S_L, TARGET } from '../../constants'; | ||
import { ButtonPrivate } from '../../helperComponents'; | ||
import { extractCommonButtonProps } from '../../utils'; | ||
import styles from './styles.module.css'; | ||
const ForwardedButtonOutline = forwardRef((_a, ref) => { | ||
var { className, size = SizeSL.S, target = Target.Blank, type = HtmlType.Button, appearance = Appearance.Primary, tabIndex } = _a, rest = __rest(_a, ["className", "size", "target", "type", "appearance", "tabIndex"]); | ||
export const ButtonOutline = forwardRef((_a, ref) => { | ||
var { className, size = SIZE_S_L.S, target = TARGET.Blank, type = HTML_TYPE.Button, appearance = APPEARANCE.Primary, tabIndex } = _a, rest = __rest(_a, ["className", "size", "target", "type", "appearance", "tabIndex"]); | ||
return (_jsx(ButtonPrivate, Object.assign({}, extractSupportProps(rest), extractCommonButtonProps(rest), { className: cn(styles.button, className), iconClassName: styles.icon, labelClassName: styles.label, size: size, target: target, type: type, appearance: appearance, tabIndex: tabIndex, ref: ref }))); | ||
}); | ||
export const ButtonOutline = ForwardedButtonOutline; | ||
ButtonOutline.sizes = SizeSL; | ||
ButtonOutline.types = HtmlType; | ||
ButtonOutline.appearances = Appearance; | ||
ButtonOutline.targets = Target; |
/// <reference types="react" /> | ||
import { WithSupportProps } from '@snack-uikit/utils'; | ||
import { Appearance, HtmlType, SizeSL, Target } from '../../constants'; | ||
import { CommonButtonProps } from '../../types'; | ||
import { CommonButtonProps, SizeSL } from '../../types'; | ||
export type ButtonSimpleProps = WithSupportProps<Omit<CommonButtonProps, 'iconPosition' | 'size'> & { | ||
@@ -12,7 +11,2 @@ size?: SizeSL; | ||
size?: SizeSL | undefined; | ||
} & import("react").RefAttributes<HTMLAnchorElement | HTMLButtonElement>> & { | ||
types: typeof HtmlType; | ||
sizes: typeof SizeSL; | ||
appearances: typeof Appearance; | ||
targets: typeof Target; | ||
}; | ||
} & import("react").RefAttributes<HTMLAnchorElement | HTMLButtonElement>>; |
@@ -16,14 +16,9 @@ var __rest = (this && this.__rest) || function (s, e) { | ||
import { extractSupportProps } from '@snack-uikit/utils'; | ||
import { Appearance, HtmlType, SizeSL, Target } from '../../constants'; | ||
import { APPEARANCE, HTML_TYPE, SIZE_S_L, TARGET } from '../../constants'; | ||
import { ButtonPrivate } from '../../helperComponents'; | ||
import { extractCommonButtonProps } from '../../utils'; | ||
import styles from './styles.module.css'; | ||
const ForwardedButtonSimple = forwardRef((_a, ref) => { | ||
var { className, size = SizeSL.S, target = Target.Blank, type = HtmlType.Button, appearance = Appearance.Neutral, tabIndex } = _a, rest = __rest(_a, ["className", "size", "target", "type", "appearance", "tabIndex"]); | ||
export const ButtonSimple = forwardRef((_a, ref) => { | ||
var { className, size = SIZE_S_L.S, target = TARGET.Blank, type = HTML_TYPE.Button, appearance = APPEARANCE.Neutral, tabIndex } = _a, rest = __rest(_a, ["className", "size", "target", "type", "appearance", "tabIndex"]); | ||
return (_jsx(ButtonPrivate, Object.assign({}, extractSupportProps(rest), extractCommonButtonProps(rest), { className: cn(styles.button, className), iconClassName: styles.icon, labelClassName: styles.label, size: size, target: target, type: type, appearance: appearance, tabIndex: tabIndex, ref: ref }))); | ||
}); | ||
export const ButtonSimple = ForwardedButtonSimple; | ||
ButtonSimple.sizes = SizeSL; | ||
ButtonSimple.types = HtmlType; | ||
ButtonSimple.appearances = Appearance; | ||
ButtonSimple.targets = Target; |
/// <reference types="react" /> | ||
import { WithSupportProps } from '@snack-uikit/utils'; | ||
import { Appearance, HtmlType, SizeSL, Target } from '../../constants'; | ||
import { CommonButtonProps } from '../../types'; | ||
import { CommonButtonProps, SizeSL } from '../../types'; | ||
export type ButtonTonalProps = WithSupportProps<Omit<CommonButtonProps, 'iconPosition' | 'size'> & { | ||
@@ -12,7 +11,2 @@ size?: SizeSL; | ||
size?: SizeSL | undefined; | ||
} & import("react").RefAttributes<HTMLAnchorElement | HTMLButtonElement>> & { | ||
types: typeof HtmlType; | ||
sizes: typeof SizeSL; | ||
appearances: typeof Appearance; | ||
targets: typeof Target; | ||
}; | ||
} & import("react").RefAttributes<HTMLAnchorElement | HTMLButtonElement>>; |
@@ -16,14 +16,9 @@ var __rest = (this && this.__rest) || function (s, e) { | ||
import { extractSupportProps } from '@snack-uikit/utils'; | ||
import { Appearance, HtmlType, SizeSL, Target } from '../../constants'; | ||
import { APPEARANCE, HTML_TYPE, SIZE_S_L, TARGET } from '../../constants'; | ||
import { ButtonPrivate } from '../../helperComponents'; | ||
import { extractCommonButtonProps } from '../../utils'; | ||
import styles from './styles.module.css'; | ||
const ForwardedButtonTonal = forwardRef((_a, ref) => { | ||
var { className, size = SizeSL.S, target = Target.Blank, type = HtmlType.Button, appearance = Appearance.Primary, tabIndex } = _a, rest = __rest(_a, ["className", "size", "target", "type", "appearance", "tabIndex"]); | ||
export const ButtonTonal = forwardRef((_a, ref) => { | ||
var { className, size = SIZE_S_L.S, target = TARGET.Blank, type = HTML_TYPE.Button, appearance = APPEARANCE.Primary, tabIndex } = _a, rest = __rest(_a, ["className", "size", "target", "type", "appearance", "tabIndex"]); | ||
return (_jsx(ButtonPrivate, Object.assign({}, extractSupportProps(rest), extractCommonButtonProps(rest), { className: cn(styles.button, className), iconClassName: styles.icon, labelClassName: styles.label, size: size, target: target, type: type, appearance: appearance, tabIndex: tabIndex, ref: ref }))); | ||
}); | ||
export const ButtonTonal = ForwardedButtonTonal; | ||
ButtonTonal.sizes = SizeSL; | ||
ButtonTonal.types = HtmlType; | ||
ButtonTonal.appearances = Appearance; | ||
ButtonTonal.targets = Target; |
@@ -1,30 +0,30 @@ | ||
export declare enum Appearance { | ||
Primary = "primary", | ||
Neutral = "neutral", | ||
Destructive = "destructive" | ||
} | ||
export declare enum HtmlType { | ||
Button = "button", | ||
Submit = "submit", | ||
Reset = "reset" | ||
} | ||
export declare enum Target { | ||
Blank = "_blank", | ||
Self = "_self", | ||
Parent = "_parent", | ||
Top = "_top" | ||
} | ||
export declare enum SizeXsM { | ||
Xs = "xs", | ||
S = "s", | ||
M = "m" | ||
} | ||
export declare enum SizeSL { | ||
S = "s", | ||
M = "m", | ||
L = "l" | ||
} | ||
export declare enum IconPosition { | ||
Before = "before", | ||
After = "after" | ||
} | ||
export declare const APPEARANCE: { | ||
readonly Primary: "primary"; | ||
readonly Neutral: "neutral"; | ||
readonly Destructive: "destructive"; | ||
}; | ||
export declare const HTML_TYPE: { | ||
readonly Button: "button"; | ||
readonly Submit: "submit"; | ||
readonly Reset: "reset"; | ||
}; | ||
export declare const TARGET: { | ||
readonly Blank: "_blank"; | ||
readonly Self: "_self"; | ||
readonly Parent: "_parent"; | ||
readonly Top: "_top"; | ||
}; | ||
export declare const SIZE_XS_M: { | ||
readonly Xs: "xs"; | ||
readonly S: "s"; | ||
readonly M: "m"; | ||
}; | ||
export declare const SIZE_S_L: { | ||
readonly S: "s"; | ||
readonly M: "m"; | ||
readonly L: "l"; | ||
}; | ||
export declare const ICON_POSITION: { | ||
readonly Before: "before"; | ||
readonly After: "after"; | ||
}; |
@@ -1,36 +0,30 @@ | ||
export var Appearance; | ||
(function (Appearance) { | ||
Appearance["Primary"] = "primary"; | ||
Appearance["Neutral"] = "neutral"; | ||
Appearance["Destructive"] = "destructive"; | ||
})(Appearance || (Appearance = {})); | ||
export var HtmlType; | ||
(function (HtmlType) { | ||
HtmlType["Button"] = "button"; | ||
HtmlType["Submit"] = "submit"; | ||
HtmlType["Reset"] = "reset"; | ||
})(HtmlType || (HtmlType = {})); | ||
export var Target; | ||
(function (Target) { | ||
Target["Blank"] = "_blank"; | ||
Target["Self"] = "_self"; | ||
Target["Parent"] = "_parent"; | ||
Target["Top"] = "_top"; | ||
})(Target || (Target = {})); | ||
export var SizeXsM; | ||
(function (SizeXsM) { | ||
SizeXsM["Xs"] = "xs"; | ||
SizeXsM["S"] = "s"; | ||
SizeXsM["M"] = "m"; | ||
})(SizeXsM || (SizeXsM = {})); | ||
export var SizeSL; | ||
(function (SizeSL) { | ||
SizeSL["S"] = "s"; | ||
SizeSL["M"] = "m"; | ||
SizeSL["L"] = "l"; | ||
})(SizeSL || (SizeSL = {})); | ||
export var IconPosition; | ||
(function (IconPosition) { | ||
IconPosition["Before"] = "before"; | ||
IconPosition["After"] = "after"; | ||
})(IconPosition || (IconPosition = {})); | ||
export const APPEARANCE = { | ||
Primary: 'primary', | ||
Neutral: 'neutral', | ||
Destructive: 'destructive', | ||
}; | ||
export const HTML_TYPE = { | ||
Button: 'button', | ||
Submit: 'submit', | ||
Reset: 'reset', | ||
}; | ||
export const TARGET = { | ||
Blank: '_blank', | ||
Self: '_self', | ||
Parent: '_parent', | ||
Top: '_top', | ||
}; | ||
export const SIZE_XS_M = { | ||
Xs: 'xs', | ||
S: 's', | ||
M: 'm', | ||
}; | ||
export const SIZE_S_L = { | ||
S: 's', | ||
M: 'm', | ||
L: 'l', | ||
}; | ||
export const ICON_POSITION = { | ||
Before: 'before', | ||
After: 'after', | ||
}; |
@@ -16,3 +16,3 @@ var __rest = (this && this.__rest) || function (s, e) { | ||
import { extractSupportProps } from '@snack-uikit/utils'; | ||
import { Appearance, HtmlType, IconPosition, Target } from '../../constants'; | ||
import { APPEARANCE, HTML_TYPE, ICON_POSITION, TARGET } from '../../constants'; | ||
import { APPEARANCE_TO_COLOR_MAP } from './constants'; | ||
@@ -22,3 +22,3 @@ import styles from './styles.module.css'; | ||
export const ButtonPrivate = forwardRef((_a, ref) => { | ||
var { className, disabled, href, icon, iconClassName, iconPosition = IconPosition.After, label, labelClassName, loading, onClick, onKeyDown, onFocus, onBlur, counter, size, target = Target.Blank, type = HtmlType.Button, appearance = Appearance.Primary, tabIndex: tabIndexProp = 0 } = _a, rest = __rest(_a, ["className", "disabled", "href", "icon", "iconClassName", "iconPosition", "label", "labelClassName", "loading", "onClick", "onKeyDown", "onFocus", "onBlur", "counter", "size", "target", "type", "appearance", "tabIndex"]); | ||
var { className, disabled, href, icon, iconClassName, iconPosition = ICON_POSITION.After, label, labelClassName, loading, onClick, onKeyDown, onFocus, onBlur, counter, size, target = TARGET.Blank, type = HTML_TYPE.Button, appearance = APPEARANCE.Primary, tabIndex: tabIndexProp = 0 } = _a, rest = __rest(_a, ["className", "disabled", "href", "icon", "iconClassName", "iconPosition", "label", "labelClassName", "loading", "onClick", "onKeyDown", "onFocus", "onBlur", "counter", "size", "target", "type", "appearance", "tabIndex"]); | ||
const variant = getVariant({ label, iconPosition, icon }); | ||
@@ -25,0 +25,0 @@ const children = getChildren({ |
@@ -7,8 +7,2 @@ export declare enum Variant { | ||
} | ||
export declare enum PrivateSize { | ||
Xs = "xs", | ||
S = "s", | ||
M = "m", | ||
L = "l" | ||
} | ||
export declare const APPEARANCE_TO_COLOR_MAP: { | ||
@@ -15,0 +9,0 @@ neutral: string; |
@@ -1,2 +0,2 @@ | ||
import { Appearance } from '../../constants'; | ||
import { APPEARANCE } from '../../constants'; | ||
export var Variant; | ||
@@ -9,13 +9,6 @@ (function (Variant) { | ||
})(Variant || (Variant = {})); | ||
export var PrivateSize; | ||
(function (PrivateSize) { | ||
PrivateSize["Xs"] = "xs"; | ||
PrivateSize["S"] = "s"; | ||
PrivateSize["M"] = "m"; | ||
PrivateSize["L"] = "l"; | ||
})(PrivateSize || (PrivateSize = {})); | ||
export const APPEARANCE_TO_COLOR_MAP = { | ||
[Appearance.Neutral]: 'neutral', | ||
[Appearance.Primary]: 'primary', | ||
[Appearance.Destructive]: 'red', | ||
[APPEARANCE.Neutral]: 'neutral', | ||
[APPEARANCE.Primary]: 'primary', | ||
[APPEARANCE.Destructive]: 'red', | ||
}; |
@@ -5,10 +5,10 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime"; | ||
import { Sun } from '@snack-uikit/loaders'; | ||
import { IconPosition } from '../../constants'; | ||
import { ICON_POSITION } from '../../constants'; | ||
import { Variant } from './constants'; | ||
import styles from './styles.module.css'; | ||
export function getVariant({ label, icon, iconPosition }) { | ||
if (label && icon && iconPosition === IconPosition.After) { | ||
if (label && icon && iconPosition === ICON_POSITION.After) { | ||
return Variant.IconAfter; | ||
} | ||
if (label && icon && iconPosition === IconPosition.Before) { | ||
if (label && icon && iconPosition === ICON_POSITION.Before) { | ||
return Variant.IconBefore; | ||
@@ -26,3 +26,3 @@ } | ||
if (loading) { | ||
return (_jsx("span", Object.assign({ "data-test-id": 'loading-icon', className: iconClassName }, { children: _jsx(Sun, { size: Sun.sizes.S }) }))); | ||
return (_jsx("span", Object.assign({ "data-test-id": 'loading-icon', className: iconClassName }, { children: _jsx(Sun, { size: 's' }) }))); | ||
} | ||
@@ -38,3 +38,3 @@ if (icon) { | ||
export function getChildren({ icon, label, iconPosition, iconClassName, labelClassName, loading, disabled, counter, }) { | ||
const counterForIcon = icon && (iconPosition === IconPosition.After || !label); | ||
const counterForIcon = icon && (iconPosition === ICON_POSITION.After || !label); | ||
const wrappedCounter = getWrappedCounter({ counter, loading, disabled, counterForIcon }); | ||
@@ -53,6 +53,6 @@ const wrappedIcon = getWrappedIcon({ | ||
switch (iconPosition) { | ||
case IconPosition.Before: { | ||
case ICON_POSITION.Before: { | ||
return (_jsxs(_Fragment, { children: [wrappedIcon, wrappedLabel] })); | ||
} | ||
case IconPosition.After: | ||
case ICON_POSITION.After: | ||
default: { | ||
@@ -59,0 +59,0 @@ return (_jsxs(_Fragment, { children: [wrappedLabel, wrappedIcon] })); |
import { AnchorHTMLAttributes, ButtonHTMLAttributes, FocusEventHandler, KeyboardEventHandler, MouseEventHandler, ReactElement } from 'react'; | ||
import { CounterProps } from '@snack-uikit/counter'; | ||
import { Appearance, IconPosition, SizeSL, SizeXsM } from './constants'; | ||
import { ValueOf } from '@snack-uikit/utils'; | ||
import { APPEARANCE, ICON_POSITION, SIZE_S_L, SIZE_XS_M } from './constants'; | ||
export type Appearance = ValueOf<typeof APPEARANCE>; | ||
export type IconPosition = ValueOf<typeof ICON_POSITION>; | ||
export type SizeSL = ValueOf<typeof SIZE_S_L>; | ||
export type SizeXsM = ValueOf<typeof SIZE_XS_M>; | ||
export type BaseButtonProps = { | ||
@@ -5,0 +10,0 @@ /** CSS-класс */ |
@@ -7,3 +7,3 @@ { | ||
"title": "Button", | ||
"version": "0.14.1", | ||
"version": "0.15.0", | ||
"sideEffects": [ | ||
@@ -36,8 +36,8 @@ "*.css", | ||
"dependencies": { | ||
"@snack-uikit/counter": "0.4.1", | ||
"@snack-uikit/loaders": "0.4.1", | ||
"@snack-uikit/utils": "3.1.0", | ||
"@snack-uikit/counter": "0.5.0", | ||
"@snack-uikit/loaders": "0.5.0", | ||
"@snack-uikit/utils": "3.2.0", | ||
"classnames": "2.3.2" | ||
}, | ||
"gitHead": "76a159dde7baccf49dc7b11e1fd7abc31424b42f" | ||
"gitHead": "bd39c5e674f3b91b0e2487782a04b15034cf3d8b" | ||
} |
@@ -17,5 +17,5 @@ # Button | ||
```typescript jsx | ||
import {ButtonFilled, ButtonFunction, ButtonSimple} from "@snack-uikit/button"; | ||
import {Counter} from "@snack-uikit/counter"; | ||
import {DaySVG} from "@snack-uikit/icons"; | ||
import { ButtonFilled, ButtonFunction, ButtonSimple } from "@snack-uikit/button"; | ||
import { Counter } from "@snack-uikit/counter"; | ||
import { DaySVG } from "@snack-uikit/icons"; | ||
@@ -26,4 +26,4 @@ <ButtonFilled | ||
icon={<DaySVG />} | ||
size={ButtonFilled.sizes.M} | ||
type={ButtonFilled.types.Critical} | ||
size='m' | ||
appearance='primary' | ||
href='https://cloud.ru/' | ||
@@ -42,3 +42,3 @@ target='_blank' | ||
value: 7, | ||
appearance: Counter.appearances.Critical, | ||
appearance: 'red', | ||
} | ||
@@ -60,3 +60,3 @@ | ||
| href | `string` | - | Ссылка | | ||
| target | `HTMLAttributeAnchorTarget` | Target.Blank | HTML-аттрибут target | | ||
| target | `HTMLAttributeAnchorTarget` | _blank | HTML-аттрибут target | | ||
| className | `string` | - | CSS-класс | | ||
@@ -71,6 +71,6 @@ | disabled | `boolean` | - | Флаг неактивности компонента | | ||
| onBlur | `FocusEventHandler<HTMLButtonElement \| HTMLAnchorElement>` | - | Колбек обработки блюра | | ||
| appearance | enum Appearance: `"primary"`, `"neutral"`, `"destructive"` | Appearance.Primary | Внешний вид кнопки | | ||
| type | "submit" \| "reset" \| "button" | HtmlType.Button | HTML-аттрибут type | | ||
| appearance | enum Appearance: `"primary"`, `"neutral"`, `"destructive"` | primary | Внешний вид кнопки | | ||
| type | "submit" \| "reset" \| "button" | button | HTML-аттрибут type | | ||
| tabIndex | `number` | - | HTML-аттрибут tab-index | | ||
| size | enum SizeSL: `"s"`, `"m"`, `"l"` | SizeSL.S | | | ||
| size | enum SizeSL: `"s"`, `"m"`, `"l"` | s | | | ||
| ref | `Ref<HTMLButtonElement \| HTMLAnchorElement>` | - | Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref). @see https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom | | ||
@@ -83,3 +83,3 @@ | key | `Key` | - | | | ||
| href | `string` | - | Ссылка | | ||
| target | `HTMLAttributeAnchorTarget` | Target.Blank | HTML-аттрибут target | | ||
| target | `HTMLAttributeAnchorTarget` | _blank | HTML-аттрибут target | | ||
| className | `string` | - | CSS-класс | | ||
@@ -94,6 +94,6 @@ | disabled | `boolean` | - | Флаг неактивности компонента | | ||
| onBlur | `FocusEventHandler<HTMLButtonElement \| HTMLAnchorElement>` | - | Колбек обработки блюра | | ||
| appearance | enum Appearance: `"primary"`, `"neutral"`, `"destructive"` | Appearance.Neutral | Внешний вид кнопки | | ||
| type | "submit" \| "reset" \| "button" | HtmlType.Button | HTML-аттрибут type | | ||
| appearance | enum Appearance: `"primary"`, `"neutral"`, `"destructive"` | neutral | Внешний вид кнопки | | ||
| type | "submit" \| "reset" \| "button" | button | HTML-аттрибут type | | ||
| tabIndex | `number` | - | HTML-аттрибут tab-index | | ||
| size | enum SizeSL: `"s"`, `"m"`, `"l"` | SizeSL.S | | | ||
| size | enum SizeSL: `"s"`, `"m"`, `"l"` | s | | | ||
| ref | `Ref<HTMLButtonElement \| HTMLAnchorElement>` | - | Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref). @see https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom | | ||
@@ -106,3 +106,3 @@ | key | `Key` | - | | | ||
| href | `string` | - | Ссылка | | ||
| target | `HTMLAttributeAnchorTarget` | Target.Blank | HTML-аттрибут target | | ||
| target | `HTMLAttributeAnchorTarget` | _blank | HTML-аттрибут target | | ||
| className | `string` | - | CSS-класс | | ||
@@ -117,6 +117,6 @@ | disabled | `boolean` | - | Флаг неактивности компонента | | ||
| onBlur | `FocusEventHandler<HTMLButtonElement \| HTMLAnchorElement>` | - | Колбек обработки блюра | | ||
| appearance | enum Appearance: `"primary"`, `"neutral"`, `"destructive"` | Appearance.Primary | Внешний вид кнопки | | ||
| type | "submit" \| "reset" \| "button" | HtmlType.Button | HTML-аттрибут type | | ||
| appearance | enum Appearance: `"primary"`, `"neutral"`, `"destructive"` | primary | Внешний вид кнопки | | ||
| type | "submit" \| "reset" \| "button" | button | HTML-аттрибут type | | ||
| tabIndex | `number` | - | HTML-аттрибут tab-index | | ||
| size | enum SizeSL: `"s"`, `"m"`, `"l"` | SizeSL.S | | | ||
| size | enum SizeSL: `"s"`, `"m"`, `"l"` | s | | | ||
| ref | `Ref<HTMLButtonElement \| HTMLAnchorElement>` | - | Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref). @see https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom | | ||
@@ -129,3 +129,3 @@ | key | `Key` | - | | | ||
| href | `string` | - | Ссылка | | ||
| target | `HTMLAttributeAnchorTarget` | Target.Blank | HTML-аттрибут target | | ||
| target | `HTMLAttributeAnchorTarget` | _blank | HTML-аттрибут target | | ||
| className | `string` | - | CSS-класс | | ||
@@ -140,6 +140,6 @@ | disabled | `boolean` | - | Флаг неактивности компонента | | ||
| onBlur | `FocusEventHandler<HTMLButtonElement \| HTMLAnchorElement>` | - | Колбек обработки блюра | | ||
| appearance | enum Appearance: `"primary"`, `"neutral"`, `"destructive"` | Appearance.Primary | Внешний вид кнопки | | ||
| type | "submit" \| "reset" \| "button" | HtmlType.Button | HTML-аттрибут type | | ||
| appearance | enum Appearance: `"primary"`, `"neutral"`, `"destructive"` | primary | Внешний вид кнопки | | ||
| type | "submit" \| "reset" \| "button" | button | HTML-аттрибут type | | ||
| tabIndex | `number` | - | HTML-аттрибут tab-index | | ||
| size | enum SizeSL: `"s"`, `"m"`, `"l"` | SizeSL.S | | | ||
| size | enum SizeSL: `"s"`, `"m"`, `"l"` | s | | | ||
| ref | `Ref<HTMLButtonElement \| HTMLAnchorElement>` | - | Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref). @see https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom | | ||
@@ -151,5 +151,5 @@ | key | `Key` | - | | | ||
|------|------|---------------|-------------| | ||
| iconPosition | enum IconPosition: `"before"`, `"after"` | IconPosition.After | Позиция иконки | | ||
| iconPosition | enum IconPosition: `"before"`, `"after"` | after | Позиция иконки | | ||
| href | `string` | - | Ссылка | | ||
| target | `HTMLAttributeAnchorTarget` | Target.Blank | HTML-аттрибут target | | ||
| target | `HTMLAttributeAnchorTarget` | _blank | HTML-аттрибут target | | ||
| className | `string` | - | CSS-класс | | ||
@@ -164,6 +164,6 @@ | disabled | `boolean` | - | Флаг неактивности компонента | | ||
| onBlur | `FocusEventHandler<HTMLButtonElement \| HTMLAnchorElement>` | - | Колбек обработки блюра | | ||
| appearance | enum Appearance: `"primary"`, `"neutral"`, `"destructive"` | Appearance.Neutral | Внешний вид кнопки | | ||
| type | "submit" \| "reset" \| "button" | HtmlType.Button | HTML-аттрибут type | | ||
| appearance | enum Appearance: `"primary"`, `"neutral"`, `"destructive"` | neutral | Внешний вид кнопки | | ||
| type | "submit" \| "reset" \| "button" | button | HTML-аттрибут type | | ||
| tabIndex | `number` | - | HTML-аттрибут tab-index | | ||
| size | enum SizeXsM: `"xs"`, `"s"`, `"m"` | SizeXsM.S | | | ||
| size | enum SizeXsM: `"s"`, `"m"`, `"xs"` | s | | | ||
| counter | `CounterInButtonProps` | - | Пропсы каунтера в кнопке | | ||
@@ -177,3 +177,3 @@ | ref | `Ref<HTMLButtonElement \| HTMLAnchorElement>` | - | Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref). @see https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom | | ||
| href | `string` | - | Ссылка | | ||
| target | `HTMLAttributeAnchorTarget` | Target.Blank | HTML-аттрибут target | | ||
| target | `HTMLAttributeAnchorTarget` | _blank | HTML-аттрибут target | | ||
| className | `string` | - | CSS-класс | | ||
@@ -187,5 +187,5 @@ | disabled | `boolean` | - | Флаг неактивности компонента | | ||
| onBlur | `FocusEventHandler<HTMLButtonElement \| HTMLAnchorElement>` | - | Колбек обработки блюра | | ||
| type | "submit" \| "reset" \| "button" | HtmlType.Button | HTML-аттрибут type | | ||
| type | "submit" \| "reset" \| "button" | button | HTML-аттрибут type | | ||
| tabIndex | `number` | - | HTML-аттрибут tab-index | | ||
| size | enum Size: `"xs"`, `"s"`, `"m"`, `"l"` | Size.S | Размер | | ||
| size | enum Size: `"s"`, `"m"`, `"l"`, `"xs"` | s | Размер | | ||
| ref | `Ref<HTMLButtonElement \| HTMLAnchorElement>` | - | Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref). @see https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom | | ||
@@ -192,0 +192,0 @@ | key | `Key` | - | | |
@@ -1,6 +0,6 @@ | ||
export enum Size { | ||
Xs = 'xs', | ||
S = 's', | ||
M = 'm', | ||
L = 'l', | ||
} | ||
export const SIZE = { | ||
Xs: 'xs', | ||
S: 's', | ||
M: 'm', | ||
L: 'l', | ||
} as const; |
@@ -1,35 +0,35 @@ | ||
export enum Appearance { | ||
Primary = 'primary', | ||
Neutral = 'neutral', | ||
Destructive = 'destructive', | ||
} | ||
export const APPEARANCE = { | ||
Primary: 'primary', | ||
Neutral: 'neutral', | ||
Destructive: 'destructive', | ||
} as const; | ||
export enum HtmlType { | ||
Button = 'button', | ||
Submit = 'submit', | ||
Reset = 'reset', | ||
} | ||
export const HTML_TYPE = { | ||
Button: 'button', | ||
Submit: 'submit', | ||
Reset: 'reset', | ||
} as const; | ||
export enum Target { | ||
Blank = '_blank', | ||
Self = '_self', | ||
Parent = '_parent', | ||
Top = '_top', | ||
} | ||
export const TARGET = { | ||
Blank: '_blank', | ||
Self: '_self', | ||
Parent: '_parent', | ||
Top: '_top', | ||
} as const; | ||
export enum SizeXsM { | ||
Xs = 'xs', | ||
S = 's', | ||
M = 'm', | ||
} | ||
export const SIZE_XS_M = { | ||
Xs: 'xs', | ||
S: 's', | ||
M: 'm', | ||
} as const; | ||
export enum SizeSL { | ||
S = 's', | ||
M = 'm', | ||
L = 'l', | ||
} | ||
export const SIZE_S_L = { | ||
S: 's', | ||
M: 'm', | ||
L: 'l', | ||
} as const; | ||
export enum IconPosition { | ||
Before = 'before', | ||
After = 'after', | ||
} | ||
export const ICON_POSITION = { | ||
Before: 'before', | ||
After: 'after', | ||
} as const; |
@@ -1,2 +0,2 @@ | ||
import { Appearance } from '../../constants'; | ||
import { APPEARANCE } from '../../constants'; | ||
@@ -10,13 +10,6 @@ export enum Variant { | ||
export enum PrivateSize { | ||
Xs = 'xs', | ||
S = 's', | ||
M = 'm', | ||
L = 'l', | ||
} | ||
export const APPEARANCE_TO_COLOR_MAP = { | ||
[Appearance.Neutral]: 'neutral', | ||
[Appearance.Primary]: 'primary', | ||
[Appearance.Destructive]: 'red', | ||
[APPEARANCE.Neutral]: 'neutral', | ||
[APPEARANCE.Primary]: 'primary', | ||
[APPEARANCE.Destructive]: 'red', | ||
}; |
@@ -11,5 +11,14 @@ import { | ||
import { CounterProps } from '@snack-uikit/counter'; | ||
import { ValueOf } from '@snack-uikit/utils'; | ||
import { Appearance, IconPosition, SizeSL, SizeXsM } from './constants'; | ||
import { APPEARANCE, ICON_POSITION, SIZE_S_L, SIZE_XS_M } from './constants'; | ||
export type Appearance = ValueOf<typeof APPEARANCE>; | ||
export type IconPosition = ValueOf<typeof ICON_POSITION>; | ||
export type SizeSL = ValueOf<typeof SIZE_S_L>; | ||
export type SizeXsM = ValueOf<typeof SIZE_XS_M>; | ||
export type BaseButtonProps = { | ||
@@ -16,0 +25,0 @@ /** CSS-класс */ |
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
93
163963
2645
+ Added@snack-uikit/counter@0.5.0(transitive)
+ Added@snack-uikit/loaders@0.5.0(transitive)
+ Added@snack-uikit/utils@3.2.0(transitive)
- Removed@snack-uikit/counter@0.4.1(transitive)
- Removed@snack-uikit/loaders@0.4.1(transitive)
- Removed@snack-uikit/utils@3.1.0(transitive)
Updated@snack-uikit/counter@0.5.0
Updated@snack-uikit/loaders@0.5.0
Updated@snack-uikit/utils@3.2.0