react-jupiter 6.3.5 → 6.3.6
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/button/index.js +88 -53
- package/package.json +1 -1
package/button/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const _excluded=["styleType","mainColor","size","icon","iconPosition","wide","disabled","type","linkTo","renderLink","variant","htmlType","isLoading","loadingText","linkTarget","children","className","onClick","aria-label"];Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _react=_interopRequireDefault(require("react")),_tailwindMerge=require("tailwind-merge"),_icon=_interopRequireDefault(require("../icon")),_theme=require("./theme");function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function _extends(){return _extends=Object.assign?Object.assign.bind():function(a){for(var b,c=1;c<arguments.length;c++)for(var d in b=arguments[c],b)({}).hasOwnProperty.call(b,d)&&(a[d]=b[d]);return a},_extends.apply(null,arguments)}function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}function _defineProperty(a,b,c){return(b=_toPropertyKey(b))in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"==typeof b?b:b+""}function _toPrimitive(a,b){if("object"!=typeof a||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){var d=c.call(a,b||"default");if("object"!=typeof d)return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}function _objectWithoutProperties(a,b){if(null==a)return{};var c,d,e=_objectWithoutPropertiesLoose(a,b);if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(a);for(d=0;d<f.length;d++)c=f[d],-1===b.indexOf(c)&&{}.propertyIsEnumerable.call(a,c)&&(e[c]=a[c])}return e}function _objectWithoutPropertiesLoose(a,b){if(null==a)return{};var c={};for(var d in a)if({}.hasOwnProperty.call(a,d)){if(-1!==b.indexOf(d))continue;c[d]=a[d]}return c}const
|
|
1
|
+
"use strict";const _excluded=["styleType","mainColor","size","icon","iconPosition","wide","disabled","type","linkTo","renderLink","variant","htmlType","isLoading","loadingText","linkTarget","textColor","children","className","onClick","aria-label"];Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _react=_interopRequireDefault(require("react")),_tailwindMerge=require("tailwind-merge"),_icon=_interopRequireDefault(require("../icon")),_theme=require("./theme");function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function _extends(){return _extends=Object.assign?Object.assign.bind():function(a){for(var b,c=1;c<arguments.length;c++)for(var d in b=arguments[c],b)({}).hasOwnProperty.call(b,d)&&(a[d]=b[d]);return a},_extends.apply(null,arguments)}function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}function _defineProperty(a,b,c){return(b=_toPropertyKey(b))in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"==typeof b?b:b+""}function _toPrimitive(a,b){if("object"!=typeof a||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){var d=c.call(a,b||"default");if("object"!=typeof d)return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}function _objectWithoutProperties(a,b){if(null==a)return{};var c,d,e=_objectWithoutPropertiesLoose(a,b);if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(a);for(d=0;d<f.length;d++)c=f[d],-1===b.indexOf(c)&&{}.propertyIsEnumerable.call(a,c)&&(e[c]=a[c])}return e}function _objectWithoutPropertiesLoose(a,b){if(null==a)return{};var c={};for(var d in a)if({}.hasOwnProperty.call(a,d)){if(-1!==b.indexOf(d))continue;c[d]=a[d]}return c}const
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
@@ -6,8 +6,7 @@
|
|
|
6
6
|
base="inline-flex items-center justify-center border box-border rounded-sm font-semibold transition-all duration-250 focus:outline-hidden focus-visible:ring-2 focus-visible:ring-offset-2 disabled:opacity-50 disabled:cursor-not-allowed active:scale-[0.98]",
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
const d={
|
|
9
|
+
presetColorClasses={
|
|
11
10
|
darkBlue:{
|
|
12
11
|
primary:"bg-main border-main text-white hover:bg-main/80 active:bg-main/95 focus-visible:ring-main",
|
|
13
12
|
secondary:"bg-transparent border-main text-main hover:bg-blue-50 active:bg-blue-100 focus-visible:ring-main",
|
|
@@ -38,9 +37,38 @@ primary:"bg-gray-600 border-gray-600 text-white hover:bg-gray-700 active:bg-gray
|
|
|
38
37
|
secondary:"bg-transparent border-gray-600 text-gray-600 hover:bg-gray-50 active:bg-gray-100 focus-visible:ring-gray-600",
|
|
39
38
|
tertiary:"bg-transparent border-transparent text-gray-600 hover:bg-gray-50 active:bg-gray-100 focus-visible:ring-gray-600"
|
|
40
39
|
}
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
getStyleClasses=(a,b)=>{
|
|
49
|
+
// Check if it's a known preset color
|
|
50
|
+
if(presetColorClasses[b])
|
|
51
|
+
return presetColorClasses[b][a]||presetColorClasses[b].primary;
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
// Tailwind color token (e.g., "green-400") — use as standard Tailwind utility
|
|
55
|
+
// These are static classes that Tailwind JIT can discover at build time
|
|
56
|
+
if(/^[a-z]+-\d+$/.test(b)){
|
|
57
|
+
const c={
|
|
58
|
+
primary:"bg-".concat(b," border-").concat(b," text-white hover:bg-").concat(b,"/80 active:bg-").concat(b,"/70 focus-visible:ring-").concat(b),
|
|
59
|
+
secondary:"bg-transparent border-".concat(b," text-").concat(b," hover:bg-").concat(b,"/10 active:bg-").concat(b,"/20 focus-visible:ring-").concat(b),
|
|
60
|
+
tertiary:"bg-transparent border-transparent text-".concat(b," hover:bg-").concat(b,"/10 active:bg-").concat(b,"/20 focus-visible:ring-").concat(b)
|
|
41
61
|
};
|
|
62
|
+
return c[a]||c.primary
|
|
63
|
+
}
|
|
42
64
|
|
|
43
|
-
|
|
65
|
+
// Custom CSS color (hex, rgb, CSS variable) — use arbitrary brackets
|
|
66
|
+
const c={
|
|
67
|
+
primary:"bg-[".concat(b,"] border-[").concat(b,"] text-white hover:bg-[").concat(b,"]/80 active:bg-[").concat(b,"]/70 focus-visible:ring-[").concat(b,"]"),
|
|
68
|
+
secondary:"bg-transparent border-[".concat(b,"] text-[").concat(b,"] hover:bg-[").concat(b,"]/10 active:bg-[").concat(b,"]/20 focus-visible:ring-[").concat(b,"]"),
|
|
69
|
+
tertiary:"bg-transparent border-transparent text-[".concat(b,"] hover:bg-[").concat(b,"]/10 active:bg-[").concat(b,"]/20 focus-visible:ring-[").concat(b,"]")
|
|
70
|
+
};
|
|
71
|
+
return c[a]||c.primary
|
|
44
72
|
},
|
|
45
73
|
|
|
46
74
|
|
|
@@ -91,94 +119,101 @@ Button=(a)=>
|
|
|
91
119
|
|
|
92
120
|
|
|
93
121
|
|
|
122
|
+
|
|
94
123
|
|
|
95
124
|
|
|
96
125
|
{let{// Old API props
|
|
97
|
-
styleType:
|
|
98
|
-
variant:b,htmlType:c,isLoading:
|
|
99
|
-
|
|
100
|
-
|
|
126
|
+
styleType:h="primary",mainColor:i="darkBlue",size:j="md",icon:k=null,iconPosition:l="left",wide:m=!1,disabled:n=!1,type:o="button",linkTo:p=null,renderLink:q=null,// New API props
|
|
127
|
+
variant:b,htmlType:c,isLoading:r=!1,loadingText:s="\u0635\u0628\u0631 \u06A9\u0646\u06CC\u062F...",linkTarget:t="_self",textColor:d,children:e,className:u="",onClick:f,"aria-label":g}=a,v=_objectWithoutProperties(a,_excluded);const w=b||(i?colorToVariant[i]:h),x=c||("anchor"===o?void 0:o),
|
|
128
|
+
y=n||r,
|
|
129
|
+
z=k&&!e,
|
|
101
130
|
|
|
102
|
-
|
|
131
|
+
A=getStyleClasses(h,i),
|
|
103
132
|
|
|
104
|
-
|
|
133
|
+
B=(0,_tailwindMerge.twMerge)(
|
|
105
134
|
base,
|
|
106
|
-
_theme.sizes[
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
135
|
+
_theme.sizes[j],
|
|
136
|
+
A,
|
|
137
|
+
d,
|
|
138
|
+
m?"w-full":"",
|
|
139
|
+
z?"p-2":"",
|
|
140
|
+
u
|
|
111
141
|
),
|
|
112
142
|
|
|
113
|
-
|
|
143
|
+
C=/*#__PURE__*/
|
|
114
144
|
_react.default.createElement(_react.default.Fragment,null,
|
|
115
|
-
|
|
145
|
+
r&&/*#__PURE__*/
|
|
116
146
|
_react.default.createElement(_icon.default,{
|
|
117
147
|
name:"loading",
|
|
118
|
-
size:iconSizeMap[
|
|
148
|
+
size:iconSizeMap[j],
|
|
119
149
|
className:"animate-spin ms-2"}
|
|
120
150
|
),
|
|
121
151
|
|
|
122
|
-
!
|
|
152
|
+
!r&&k&&"left"===l&&/*#__PURE__*/
|
|
123
153
|
_react.default.createElement(_icon.default,{
|
|
124
|
-
name:
|
|
125
|
-
size:iconSizeMap[
|
|
126
|
-
className:
|
|
154
|
+
name:k,
|
|
155
|
+
size:iconSizeMap[j],
|
|
156
|
+
className:e?"ml-2":""}
|
|
127
157
|
),
|
|
128
158
|
|
|
129
|
-
|
|
130
|
-
!
|
|
159
|
+
r?s:e,
|
|
160
|
+
!r&&k&&"right"===l&&/*#__PURE__*/
|
|
131
161
|
_react.default.createElement(_icon.default,{
|
|
132
|
-
name:
|
|
133
|
-
size:iconSizeMap[
|
|
134
|
-
className:
|
|
162
|
+
name:k,
|
|
163
|
+
size:iconSizeMap[j],
|
|
164
|
+
className:e?"mr-2":""}
|
|
135
165
|
)
|
|
136
166
|
|
|
137
167
|
),
|
|
138
168
|
|
|
139
169
|
|
|
140
|
-
|
|
141
|
-
type:
|
|
142
|
-
className:
|
|
143
|
-
disabled:
|
|
144
|
-
onClick:
|
|
145
|
-
"aria-disabled":
|
|
146
|
-
"aria-busy":
|
|
147
|
-
"aria-label":
|
|
148
|
-
|
|
170
|
+
D=_objectSpread({
|
|
171
|
+
type:p||q?void 0:x,
|
|
172
|
+
className:B,
|
|
173
|
+
disabled:y,
|
|
174
|
+
onClick:y?void 0:f,
|
|
175
|
+
"aria-disabled":y,
|
|
176
|
+
"aria-busy":r,
|
|
177
|
+
"aria-label":z?g||k:void 0},
|
|
178
|
+
v);return(
|
|
149
179
|
|
|
150
180
|
|
|
151
|
-
!
|
|
152
|
-
|
|
153
|
-
_react.default.createElement("button",_extends({},
|
|
154
|
-
|
|
181
|
+
!y&&q)?
|
|
182
|
+
q(/*#__PURE__*/
|
|
183
|
+
_react.default.createElement("button",_extends({},D,{type:"button"}),
|
|
184
|
+
C
|
|
155
185
|
)
|
|
156
186
|
):
|
|
157
187
|
|
|
158
188
|
|
|
159
|
-
!
|
|
189
|
+
!y&&p?/*#__PURE__*/
|
|
160
190
|
|
|
161
191
|
_react.default.createElement("a",_extends({
|
|
162
|
-
href:
|
|
163
|
-
target:
|
|
164
|
-
className:
|
|
192
|
+
href:p,
|
|
193
|
+
target:t,
|
|
194
|
+
className:B,
|
|
165
195
|
role:"button",
|
|
166
|
-
"aria-disabled":
|
|
167
|
-
"aria-busy":
|
|
168
|
-
"aria-label":
|
|
169
|
-
|
|
196
|
+
"aria-disabled":y,
|
|
197
|
+
"aria-busy":r,
|
|
198
|
+
"aria-label":z?g||k:void 0},
|
|
199
|
+
v),
|
|
170
200
|
|
|
171
|
-
|
|
201
|
+
C
|
|
172
202
|
):/*#__PURE__*/
|
|
173
203
|
|
|
174
204
|
|
|
175
205
|
|
|
176
206
|
|
|
177
|
-
_react.default.createElement("button",
|
|
178
|
-
|
|
207
|
+
_react.default.createElement("button",D,
|
|
208
|
+
C
|
|
179
209
|
)
|
|
180
210
|
|
|
181
|
-
};// Style type templates
|
|
182
|
-
|
|
211
|
+
};// Style type templates for preset colors
|
|
212
|
+
/**
|
|
213
|
+
* Generates Tailwind classes for a given styleType and color.
|
|
214
|
+
* - Preset colors (darkBlue, red, green, etc.) → predefined classes
|
|
215
|
+
* - Tailwind tokens (green-400, slate-100) → standard Tailwind utility classes
|
|
216
|
+
* - Custom CSS colors (#FF5733, rgb(...), var(--css-var)) → arbitrary value brackets `bg-[value]`
|
|
217
|
+
*/// Color mapping
|
|
183
218
|
// Map old icon names to Heroicons
|
|
184
219
|
var _default=exports.default=Button;
|