@zenkigen-inc/component-ui 1.9.2 → 1.9.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/button/button.d.ts +9 -19
- package/dist/index.esm.js +30 -40
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +33 -42
- 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", {
|
|
@@ -31957,6 +31944,8 @@ function PaginationSelect(_ref) {
|
|
|
31957
31944
|
label: value
|
|
31958
31945
|
};
|
|
31959
31946
|
});
|
|
31947
|
+
var minCount = totalSize ? (currentPage - 1) * sizePerPage + 1 : 0;
|
|
31948
|
+
var maxCount = currentPage * sizePerPage > totalSize ? totalSize : currentPage * sizePerPage;
|
|
31960
31949
|
return /*#__PURE__*/jsxs("nav", {
|
|
31961
31950
|
"aria-label": "pagination",
|
|
31962
31951
|
className: "flex items-center gap-x-1",
|
|
@@ -31964,7 +31953,7 @@ function PaginationSelect(_ref) {
|
|
|
31964
31953
|
className: "flex items-center gap-x-2",
|
|
31965
31954
|
children: [/*#__PURE__*/jsxs("div", {
|
|
31966
31955
|
className: "typography-label2regular text-text01",
|
|
31967
|
-
children: [
|
|
31956
|
+
children: [minCount > 0 && minCount + " - ", maxCount, countLabel]
|
|
31968
31957
|
}), /*#__PURE__*/jsx(Select, {
|
|
31969
31958
|
size: "medium",
|
|
31970
31959
|
variant: "outline",
|
|
@@ -31975,6 +31964,7 @@ function PaginationSelect(_ref) {
|
|
|
31975
31964
|
onChange: function onChange(option) {
|
|
31976
31965
|
return option && _onChange(Number(option.value));
|
|
31977
31966
|
},
|
|
31967
|
+
isDisabled: pageMax === 0,
|
|
31978
31968
|
children: optionsList && optionsList.map(function (option) {
|
|
31979
31969
|
return /*#__PURE__*/jsx(Select.Option, {
|
|
31980
31970
|
option: option
|
|
@@ -31996,7 +31986,7 @@ function PaginationSelect(_ref) {
|
|
|
31996
31986
|
variant: "text",
|
|
31997
31987
|
icon: "angle-right",
|
|
31998
31988
|
size: "small",
|
|
31999
|
-
isDisabled: currentPage === pageMax,
|
|
31989
|
+
isDisabled: currentPage === pageMax || pageMax === 0,
|
|
32000
31990
|
onClick: onClickNextButton
|
|
32001
31991
|
})]
|
|
32002
31992
|
})]
|