@zenkigen-inc/component-ui 1.9.2 → 1.9.3
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/button/button.d.ts +9 -19
- package/dist/index.esm.js +25 -38
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +28 -40
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/button/button.d.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import { CSSProperties, PropsWithChildren, ReactNode } from 'react';
|
|
1
|
+
import { ComponentPropsWithoutRef, CSSProperties, ElementType, PropsWithChildren, ReactNode } from 'react';
|
|
2
2
|
type Size = 'small' | 'medium' | 'large';
|
|
3
3
|
type Variant = 'fill' | 'fillDanger' | 'outline' | 'text';
|
|
4
|
-
type
|
|
4
|
+
export type ElementAs = ElementType;
|
|
5
|
+
export type AsProp<T extends ElementAs> = {
|
|
6
|
+
elementAs?: T;
|
|
7
|
+
};
|
|
8
|
+
export type PolymorphicPropsWithoutRef<T extends ElementAs, P extends object> = PropsWithChildren<P> & ComponentPropsWithoutRef<T> & AsProp<T>;
|
|
9
|
+
type Props<T extends ElementAs> = PolymorphicPropsWithoutRef<T, {
|
|
5
10
|
size?: Size;
|
|
6
11
|
width?: CSSProperties['width'];
|
|
7
12
|
isSelected?: boolean;
|
|
@@ -10,21 +15,6 @@ type Props = {
|
|
|
10
15
|
before?: ReactNode;
|
|
11
16
|
after?: ReactNode;
|
|
12
17
|
borderRadius?: CSSProperties['borderRadius'];
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
href?: string;
|
|
16
|
-
target?: HTMLAnchorElement['target'];
|
|
17
|
-
onClick?: never;
|
|
18
|
-
} | {
|
|
19
|
-
type?: 'button';
|
|
20
|
-
href?: never;
|
|
21
|
-
target?: never;
|
|
22
|
-
onClick?: () => void;
|
|
23
|
-
} | {
|
|
24
|
-
type?: 'submit';
|
|
25
|
-
href?: never;
|
|
26
|
-
target?: never;
|
|
27
|
-
onClick?: () => void;
|
|
28
|
-
});
|
|
29
|
-
export declare const Button: import("react").ForwardRefExoticComponent<PropsWithChildren<Props> & import("react").RefAttributes<HTMLAnchorElement & HTMLButtonElement>>;
|
|
18
|
+
}>;
|
|
19
|
+
export declare const Button: <T extends ElementAs = "button">({ size, variant, isDisabled, isSelected, width, borderRadius, before, after, elementAs, children, ...props }: Props<T>) => import("react").JSX.Element;
|
|
30
20
|
export {};
|
package/dist/index.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { userColors, buttonColors, focusVisible, iconColors, typography, tagColors, tagLightColors } from '@zenkigen-inc/component-theme';
|
|
2
2
|
import clsx$1, { clsx } from 'clsx';
|
|
3
3
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
4
|
-
import aa, {
|
|
4
|
+
import aa, { useState, useCallback, useEffect, createContext, useContext, useRef, useLayoutEffect, forwardRef } from 'react';
|
|
5
5
|
import { iconElements } from '@zenkigen-inc/component-icons';
|
|
6
6
|
|
|
7
7
|
function _extends() {
|
|
@@ -78,53 +78,40 @@ function Breadcrumb(_ref) {
|
|
|
78
78
|
}
|
|
79
79
|
Breadcrumb.Item = BreadcrumbItem;
|
|
80
80
|
|
|
81
|
-
var _excluded$6 = ["size", "variant", "
|
|
82
|
-
var Button =
|
|
81
|
+
var _excluded$6 = ["size", "variant", "isDisabled", "isSelected", "width", "borderRadius", "before", "after", "elementAs", "children"];
|
|
82
|
+
var Button = function Button(_ref) {
|
|
83
83
|
var _clsx;
|
|
84
84
|
var _ref$size = _ref.size,
|
|
85
85
|
size = _ref$size === void 0 ? 'medium' : _ref$size,
|
|
86
86
|
_ref$variant = _ref.variant,
|
|
87
87
|
variant = _ref$variant === void 0 ? 'fill' : _ref$variant,
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
88
|
+
isDisabled = _ref.isDisabled,
|
|
89
|
+
isSelected = _ref.isSelected,
|
|
90
|
+
width = _ref.width,
|
|
91
|
+
borderRadius = _ref.borderRadius,
|
|
92
|
+
before = _ref.before,
|
|
93
|
+
after = _ref.after,
|
|
94
|
+
elementAs = _ref.elementAs,
|
|
95
|
+
children = _ref.children,
|
|
93
96
|
props = _objectWithoutPropertiesLoose(_ref, _excluded$6);
|
|
94
97
|
var baseClasses = clsx('flex shrink-0 items-center justify-center gap-1', buttonColors[variant].hover, buttonColors[variant].active, buttonColors[variant].disabled, focusVisible.normal, (_clsx = {
|
|
95
98
|
'h-6 px-2.5': size === 'small',
|
|
96
99
|
'h-8 px-3': size === 'medium',
|
|
97
100
|
'h-10 px-4 leading-[24px]': size === 'large',
|
|
98
|
-
'inline-flex':
|
|
99
|
-
}, _clsx[buttonColors[variant].selected] =
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
} else {
|
|
113
|
-
return /*#__PURE__*/jsxs("button", {
|
|
114
|
-
type: type === 'submit' ? 'submit' : 'button',
|
|
115
|
-
className: baseClasses,
|
|
116
|
-
disabled: props.isDisabled,
|
|
117
|
-
onClick: onClick,
|
|
118
|
-
style: {
|
|
119
|
-
width: props.width,
|
|
120
|
-
borderRadius: props.borderRadius
|
|
121
|
-
},
|
|
122
|
-
ref: ref,
|
|
123
|
-
children: [props.before, props.children, props.after]
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
Button.displayName = 'Button';
|
|
101
|
+
'inline-flex': elementAs === 'a'
|
|
102
|
+
}, _clsx[buttonColors[variant].selected] = isSelected, _clsx[buttonColors[variant].base] = !isSelected, _clsx['hover:text-textOnColor active:text-textOnColor [&:hover>*]:fill-iconOnColor [&:active>*]:fill-iconOnColor'] = props.isSelected && variant !== 'outline' && variant !== 'text', _clsx['pointer-events-none'] = isDisabled, _clsx['rounded-button'] = !borderRadius, _clsx['typography-label1regular'] = size === 'large', _clsx['typography-label2regular'] = size !== 'large', _clsx));
|
|
103
|
+
var Component = elementAs || 'button';
|
|
104
|
+
return /*#__PURE__*/jsxs(Component, _extends({
|
|
105
|
+
className: baseClasses,
|
|
106
|
+
style: {
|
|
107
|
+
width: width,
|
|
108
|
+
borderRadius: borderRadius
|
|
109
|
+
},
|
|
110
|
+
disabled: isDisabled
|
|
111
|
+
}, props, {
|
|
112
|
+
children: [before, children, after]
|
|
113
|
+
}));
|
|
114
|
+
};
|
|
128
115
|
|
|
129
116
|
var CheckedIcon = function CheckedIcon() {
|
|
130
117
|
return /*#__PURE__*/jsx("svg", {
|