@vinyasa/button 1.0.22 → 1.0.24
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/cjs/button.cjs +276 -247
- package/dist/cjs/index.cjs +30 -14
- package/dist/esm/button.js +18 -11
- package/dist/esm/components/button/Button.d.ts +7 -2
- package/dist/esm/components/button/index.d.ts +3 -2
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +1 -1
- package/package.json +5 -5
package/dist/cjs/button.cjs
CHANGED
|
@@ -1,5 +1,269 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
2
|
+
var __webpack_modules__ = {
|
|
3
|
+
95 (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
4
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
5
|
+
a: ()=>ButtonIcon,
|
|
6
|
+
A: ()=>button_Button
|
|
7
|
+
});
|
|
8
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
9
|
+
const tokens_namespaceObject = require("@vinyasa/tokens");
|
|
10
|
+
const external_react_namespaceObject = require("react");
|
|
11
|
+
function toPrimitive(t, r) {
|
|
12
|
+
if ("object" != typeof t || !t) return t;
|
|
13
|
+
var e = t[Symbol.toPrimitive];
|
|
14
|
+
if (void 0 !== e) {
|
|
15
|
+
var i = e.call(t, r || "default");
|
|
16
|
+
if ("object" != typeof i) return i;
|
|
17
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
18
|
+
}
|
|
19
|
+
return ("string" === r ? String : Number)(t);
|
|
20
|
+
}
|
|
21
|
+
function toPropertyKey(t) {
|
|
22
|
+
var i = toPrimitive(t, "string");
|
|
23
|
+
return "symbol" == typeof i ? i : String(i);
|
|
24
|
+
}
|
|
25
|
+
function _defineProperty(obj, key, value) {
|
|
26
|
+
key = toPropertyKey(key);
|
|
27
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
28
|
+
value: value,
|
|
29
|
+
enumerable: true,
|
|
30
|
+
configurable: true,
|
|
31
|
+
writable: true
|
|
32
|
+
});
|
|
33
|
+
else obj[key] = value;
|
|
34
|
+
return obj;
|
|
35
|
+
}
|
|
36
|
+
function createRuntimeFn_62c9670f_esm_ownKeys(e, r) {
|
|
37
|
+
var t = Object.keys(e);
|
|
38
|
+
if (Object.getOwnPropertySymbols) {
|
|
39
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
40
|
+
r && (o = o.filter(function(r) {
|
|
41
|
+
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
42
|
+
})), t.push.apply(t, o);
|
|
43
|
+
}
|
|
44
|
+
return t;
|
|
45
|
+
}
|
|
46
|
+
function _objectSpread2(e) {
|
|
47
|
+
for(var r = 1; r < arguments.length; r++){
|
|
48
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
49
|
+
r % 2 ? createRuntimeFn_62c9670f_esm_ownKeys(Object(t), !0).forEach(function(r) {
|
|
50
|
+
_defineProperty(e, r, t[r]);
|
|
51
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : createRuntimeFn_62c9670f_esm_ownKeys(Object(t)).forEach(function(r) {
|
|
52
|
+
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
return e;
|
|
56
|
+
}
|
|
57
|
+
function mapValues(input, fn) {
|
|
58
|
+
var result = {};
|
|
59
|
+
for(var _key in input)result[_key] = fn(input[_key], _key);
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
var shouldApplyCompound = (compoundCheck, selections, defaultVariants)=>{
|
|
63
|
+
for (var key of Object.keys(compoundCheck)){
|
|
64
|
+
var _selections$key;
|
|
65
|
+
if (compoundCheck[key] !== (null != (_selections$key = selections[key]) ? _selections$key : defaultVariants[key])) return false;
|
|
66
|
+
}
|
|
67
|
+
return true;
|
|
68
|
+
};
|
|
69
|
+
var createRuntimeFn = (config)=>{
|
|
70
|
+
var runtimeFn = (options)=>{
|
|
71
|
+
var className = config.defaultClassName;
|
|
72
|
+
var selections = _objectSpread2(_objectSpread2({}, config.defaultVariants), options);
|
|
73
|
+
for(var variantName in selections){
|
|
74
|
+
var _selections$variantNa;
|
|
75
|
+
var variantSelection = null != (_selections$variantNa = selections[variantName]) ? _selections$variantNa : config.defaultVariants[variantName];
|
|
76
|
+
if (null != variantSelection) {
|
|
77
|
+
var selection = variantSelection;
|
|
78
|
+
if ('boolean' == typeof selection) selection = true === selection ? 'true' : 'false';
|
|
79
|
+
var selectionClassName = config.variantClassNames[variantName][selection];
|
|
80
|
+
if (selectionClassName) className += ' ' + selectionClassName;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
for (var [compoundCheck, compoundClassName] of config.compoundVariants)if (shouldApplyCompound(compoundCheck, selections, config.defaultVariants)) className += ' ' + compoundClassName;
|
|
84
|
+
return className;
|
|
85
|
+
};
|
|
86
|
+
runtimeFn.variants = ()=>Object.keys(config.variantClassNames);
|
|
87
|
+
runtimeFn.classNames = {
|
|
88
|
+
get base () {
|
|
89
|
+
return config.defaultClassName.split(' ')[0];
|
|
90
|
+
},
|
|
91
|
+
get variants () {
|
|
92
|
+
return mapValues(config.variantClassNames, (classNames)=>mapValues(classNames, (className)=>className.split(' ')[0]));
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
return runtimeFn;
|
|
96
|
+
};
|
|
97
|
+
var Button_css_button = createRuntimeFn({
|
|
98
|
+
defaultClassName: '_1bwnrav0',
|
|
99
|
+
variantClassNames: {
|
|
100
|
+
variant: {
|
|
101
|
+
primary: '_1bwnrav1',
|
|
102
|
+
secondary: '_1bwnrav2',
|
|
103
|
+
tertiary: '_1bwnrav3',
|
|
104
|
+
danger: '_1bwnrav4',
|
|
105
|
+
outline: '_1bwnrav5',
|
|
106
|
+
ghost: '_1bwnrav6'
|
|
107
|
+
},
|
|
108
|
+
size: {
|
|
109
|
+
sm: '_1bwnrav7',
|
|
110
|
+
md: '_1bwnrav8',
|
|
111
|
+
lg: '_1bwnrav9'
|
|
112
|
+
},
|
|
113
|
+
radius: {
|
|
114
|
+
sm: '_1bwnrava',
|
|
115
|
+
md: '_1bwnravb',
|
|
116
|
+
full: '_1bwnravc'
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
defaultVariants: {
|
|
120
|
+
variant: 'primary',
|
|
121
|
+
size: 'md',
|
|
122
|
+
radius: 'full'
|
|
123
|
+
},
|
|
124
|
+
compoundVariants: []
|
|
125
|
+
});
|
|
126
|
+
var spinner = '_18kjv2i1';
|
|
127
|
+
const Spinner = ()=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
128
|
+
className: spinner,
|
|
129
|
+
"aria-hidden": "true"
|
|
130
|
+
});
|
|
131
|
+
const button_Spinner = Spinner;
|
|
132
|
+
function _define_property(obj, key, value) {
|
|
133
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
134
|
+
value: value,
|
|
135
|
+
enumerable: true,
|
|
136
|
+
configurable: true,
|
|
137
|
+
writable: true
|
|
138
|
+
});
|
|
139
|
+
else obj[key] = value;
|
|
140
|
+
return obj;
|
|
141
|
+
}
|
|
142
|
+
function _object_spread(target) {
|
|
143
|
+
for(var i = 1; i < arguments.length; i++){
|
|
144
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
145
|
+
var ownKeys = Object.keys(source);
|
|
146
|
+
if ("function" == typeof Object.getOwnPropertySymbols) ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
147
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
148
|
+
}));
|
|
149
|
+
ownKeys.forEach(function(key) {
|
|
150
|
+
_define_property(target, key, source[key]);
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
return target;
|
|
154
|
+
}
|
|
155
|
+
function Button_ownKeys(object, enumerableOnly) {
|
|
156
|
+
var keys = Object.keys(object);
|
|
157
|
+
if (Object.getOwnPropertySymbols) {
|
|
158
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
159
|
+
if (enumerableOnly) symbols = symbols.filter(function(sym) {
|
|
160
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
161
|
+
});
|
|
162
|
+
keys.push.apply(keys, symbols);
|
|
163
|
+
}
|
|
164
|
+
return keys;
|
|
165
|
+
}
|
|
166
|
+
function _object_spread_props(target, source) {
|
|
167
|
+
source = null != source ? source : {};
|
|
168
|
+
if (Object.getOwnPropertyDescriptors) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
169
|
+
else Button_ownKeys(Object(source)).forEach(function(key) {
|
|
170
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
171
|
+
});
|
|
172
|
+
return target;
|
|
173
|
+
}
|
|
174
|
+
function _object_without_properties(source, excluded) {
|
|
175
|
+
if (null == source) return {};
|
|
176
|
+
var target = {}, sourceKeys, key, i;
|
|
177
|
+
if ("u" > typeof Reflect && Reflect.ownKeys) {
|
|
178
|
+
sourceKeys = Reflect.ownKeys(Object(source));
|
|
179
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
180
|
+
key = sourceKeys[i];
|
|
181
|
+
if (!(excluded.indexOf(key) >= 0)) {
|
|
182
|
+
if (Object.prototype.propertyIsEnumerable.call(source, key)) target[key] = source[key];
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return target;
|
|
186
|
+
}
|
|
187
|
+
target = _object_without_properties_loose(source, excluded);
|
|
188
|
+
if (Object.getOwnPropertySymbols) {
|
|
189
|
+
sourceKeys = Object.getOwnPropertySymbols(source);
|
|
190
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
191
|
+
key = sourceKeys[i];
|
|
192
|
+
if (!(excluded.indexOf(key) >= 0)) {
|
|
193
|
+
if (Object.prototype.propertyIsEnumerable.call(source, key)) target[key] = source[key];
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return target;
|
|
198
|
+
}
|
|
199
|
+
function _object_without_properties_loose(source, excluded) {
|
|
200
|
+
if (null == source) return {};
|
|
201
|
+
var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
|
|
202
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
203
|
+
key = sourceKeys[i];
|
|
204
|
+
if (!(excluded.indexOf(key) >= 0)) {
|
|
205
|
+
if (Object.prototype.propertyIsEnumerable.call(source, key)) target[key] = source[key];
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return target;
|
|
209
|
+
}
|
|
210
|
+
const ButtonIcon = ({ children })=>children;
|
|
211
|
+
ButtonIcon.displayName = 'ButtonIcon';
|
|
212
|
+
const isButtonIcon = (node)=>/*#__PURE__*/ (0, external_react_namespaceObject.isValidElement)(node) && node.type === ButtonIcon;
|
|
213
|
+
const Button = /*#__PURE__*/ (0, external_react_namespaceObject.forwardRef)((_0, _1)=>{
|
|
214
|
+
let _ref = [
|
|
215
|
+
_0,
|
|
216
|
+
_1
|
|
217
|
+
], [_ref1, ..._rest] = _ref, { children, variant, size, radius, loading = false, disabled = false, type = 'button', className } = _ref1, rest = _object_without_properties(_ref1, [
|
|
218
|
+
"children",
|
|
219
|
+
"variant",
|
|
220
|
+
"size",
|
|
221
|
+
"radius",
|
|
222
|
+
"loading",
|
|
223
|
+
"disabled",
|
|
224
|
+
"type",
|
|
225
|
+
"className"
|
|
226
|
+
]), [ref] = _rest;
|
|
227
|
+
const themedRef = (0, tokens_namespaceObject.useThemedRef)(ref);
|
|
228
|
+
const classes = className ? `${Button_css_button({
|
|
229
|
+
variant,
|
|
230
|
+
size,
|
|
231
|
+
radius
|
|
232
|
+
})} ${className}` : Button_css_button({
|
|
233
|
+
variant,
|
|
234
|
+
size,
|
|
235
|
+
radius
|
|
236
|
+
});
|
|
237
|
+
const childArray = external_react_namespaceObject.Children.toArray(children);
|
|
238
|
+
const hasLeadingIcon = isButtonIcon(childArray[0]);
|
|
239
|
+
const content = loading ? [
|
|
240
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(button_Spinner, {}, "spinner"),
|
|
241
|
+
...childArray.slice(hasLeadingIcon ? 1 : 0).filter((child)=>!isButtonIcon(child))
|
|
242
|
+
] : children;
|
|
243
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("button", _object_spread_props(_object_spread({
|
|
244
|
+
ref: themedRef,
|
|
245
|
+
type: type,
|
|
246
|
+
disabled: disabled || loading,
|
|
247
|
+
"aria-busy": loading || void 0,
|
|
248
|
+
className: classes
|
|
249
|
+
}, rest), {
|
|
250
|
+
children: content
|
|
251
|
+
}));
|
|
252
|
+
});
|
|
253
|
+
Button.displayName = 'Button';
|
|
254
|
+
const button_Button = Button;
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
var __webpack_module_cache__ = {};
|
|
258
|
+
function __webpack_require__(moduleId) {
|
|
259
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
260
|
+
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
261
|
+
var module = __webpack_module_cache__[moduleId] = {
|
|
262
|
+
exports: {}
|
|
263
|
+
};
|
|
264
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
265
|
+
return module.exports;
|
|
266
|
+
}
|
|
3
267
|
(()=>{
|
|
4
268
|
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
269
|
var define = (defs, kind)=>{
|
|
@@ -26,255 +290,20 @@ var __webpack_require__ = {};
|
|
|
26
290
|
};
|
|
27
291
|
})();
|
|
28
292
|
var __webpack_exports__ = {};
|
|
29
|
-
|
|
30
|
-
__webpack_require__.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
var e = t[Symbol.toPrimitive];
|
|
38
|
-
if (void 0 !== e) {
|
|
39
|
-
var i = e.call(t, r || "default");
|
|
40
|
-
if ("object" != typeof i) return i;
|
|
41
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
42
|
-
}
|
|
43
|
-
return ("string" === r ? String : Number)(t);
|
|
44
|
-
}
|
|
45
|
-
function toPropertyKey(t) {
|
|
46
|
-
var i = toPrimitive(t, "string");
|
|
47
|
-
return "symbol" == typeof i ? i : String(i);
|
|
48
|
-
}
|
|
49
|
-
function _defineProperty(obj, key, value) {
|
|
50
|
-
key = toPropertyKey(key);
|
|
51
|
-
if (key in obj) Object.defineProperty(obj, key, {
|
|
52
|
-
value: value,
|
|
53
|
-
enumerable: true,
|
|
54
|
-
configurable: true,
|
|
55
|
-
writable: true
|
|
56
|
-
});
|
|
57
|
-
else obj[key] = value;
|
|
58
|
-
return obj;
|
|
59
|
-
}
|
|
60
|
-
function createRuntimeFn_62c9670f_esm_ownKeys(e, r) {
|
|
61
|
-
var t = Object.keys(e);
|
|
62
|
-
if (Object.getOwnPropertySymbols) {
|
|
63
|
-
var o = Object.getOwnPropertySymbols(e);
|
|
64
|
-
r && (o = o.filter(function(r) {
|
|
65
|
-
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
66
|
-
})), t.push.apply(t, o);
|
|
67
|
-
}
|
|
68
|
-
return t;
|
|
69
|
-
}
|
|
70
|
-
function _objectSpread2(e) {
|
|
71
|
-
for(var r = 1; r < arguments.length; r++){
|
|
72
|
-
var t = null != arguments[r] ? arguments[r] : {};
|
|
73
|
-
r % 2 ? createRuntimeFn_62c9670f_esm_ownKeys(Object(t), !0).forEach(function(r) {
|
|
74
|
-
_defineProperty(e, r, t[r]);
|
|
75
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : createRuntimeFn_62c9670f_esm_ownKeys(Object(t)).forEach(function(r) {
|
|
76
|
-
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
return e;
|
|
80
|
-
}
|
|
81
|
-
function mapValues(input, fn) {
|
|
82
|
-
var result = {};
|
|
83
|
-
for(var _key in input)result[_key] = fn(input[_key], _key);
|
|
84
|
-
return result;
|
|
85
|
-
}
|
|
86
|
-
var shouldApplyCompound = (compoundCheck, selections, defaultVariants)=>{
|
|
87
|
-
for (var key of Object.keys(compoundCheck)){
|
|
88
|
-
var _selections$key;
|
|
89
|
-
if (compoundCheck[key] !== (null != (_selections$key = selections[key]) ? _selections$key : defaultVariants[key])) return false;
|
|
90
|
-
}
|
|
91
|
-
return true;
|
|
92
|
-
};
|
|
93
|
-
var createRuntimeFn = (config)=>{
|
|
94
|
-
var runtimeFn = (options)=>{
|
|
95
|
-
var className = config.defaultClassName;
|
|
96
|
-
var selections = _objectSpread2(_objectSpread2({}, config.defaultVariants), options);
|
|
97
|
-
for(var variantName in selections){
|
|
98
|
-
var _selections$variantNa;
|
|
99
|
-
var variantSelection = null != (_selections$variantNa = selections[variantName]) ? _selections$variantNa : config.defaultVariants[variantName];
|
|
100
|
-
if (null != variantSelection) {
|
|
101
|
-
var selection = variantSelection;
|
|
102
|
-
if ('boolean' == typeof selection) selection = true === selection ? 'true' : 'false';
|
|
103
|
-
var selectionClassName = config.variantClassNames[variantName][selection];
|
|
104
|
-
if (selectionClassName) className += ' ' + selectionClassName;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
for (var [compoundCheck, compoundClassName] of config.compoundVariants)if (shouldApplyCompound(compoundCheck, selections, config.defaultVariants)) className += ' ' + compoundClassName;
|
|
108
|
-
return className;
|
|
109
|
-
};
|
|
110
|
-
runtimeFn.variants = ()=>Object.keys(config.variantClassNames);
|
|
111
|
-
runtimeFn.classNames = {
|
|
112
|
-
get base () {
|
|
113
|
-
return config.defaultClassName.split(' ')[0];
|
|
114
|
-
},
|
|
115
|
-
get variants () {
|
|
116
|
-
return mapValues(config.variantClassNames, (classNames)=>mapValues(classNames, (className)=>className.split(' ')[0]));
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
return runtimeFn;
|
|
120
|
-
};
|
|
121
|
-
var Button_css_button = createRuntimeFn({
|
|
122
|
-
defaultClassName: '_1bwnrav0',
|
|
123
|
-
variantClassNames: {
|
|
124
|
-
variant: {
|
|
125
|
-
primary: '_1bwnrav1',
|
|
126
|
-
secondary: '_1bwnrav2',
|
|
127
|
-
tertiary: '_1bwnrav3',
|
|
128
|
-
danger: '_1bwnrav4',
|
|
129
|
-
outline: '_1bwnrav5',
|
|
130
|
-
ghost: '_1bwnrav6'
|
|
131
|
-
},
|
|
132
|
-
size: {
|
|
133
|
-
sm: '_1bwnrav7',
|
|
134
|
-
md: '_1bwnrav8',
|
|
135
|
-
lg: '_1bwnrav9'
|
|
136
|
-
},
|
|
137
|
-
radius: {
|
|
138
|
-
sm: '_1bwnrava',
|
|
139
|
-
md: '_1bwnravb',
|
|
140
|
-
full: '_1bwnravc'
|
|
141
|
-
}
|
|
142
|
-
},
|
|
143
|
-
defaultVariants: {
|
|
144
|
-
variant: 'primary',
|
|
145
|
-
size: 'md',
|
|
146
|
-
radius: 'full'
|
|
147
|
-
},
|
|
148
|
-
compoundVariants: []
|
|
149
|
-
});
|
|
150
|
-
var spinner = '_18kjv2i1';
|
|
151
|
-
const Spinner = ()=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
152
|
-
className: spinner,
|
|
153
|
-
"aria-hidden": "true"
|
|
154
|
-
});
|
|
155
|
-
const button_Spinner = Spinner;
|
|
156
|
-
function _define_property(obj, key, value) {
|
|
157
|
-
if (key in obj) Object.defineProperty(obj, key, {
|
|
158
|
-
value: value,
|
|
159
|
-
enumerable: true,
|
|
160
|
-
configurable: true,
|
|
161
|
-
writable: true
|
|
162
|
-
});
|
|
163
|
-
else obj[key] = value;
|
|
164
|
-
return obj;
|
|
165
|
-
}
|
|
166
|
-
function _object_spread(target) {
|
|
167
|
-
for(var i = 1; i < arguments.length; i++){
|
|
168
|
-
var source = null != arguments[i] ? arguments[i] : {};
|
|
169
|
-
var ownKeys = Object.keys(source);
|
|
170
|
-
if ("function" == typeof Object.getOwnPropertySymbols) ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
171
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
172
|
-
}));
|
|
173
|
-
ownKeys.forEach(function(key) {
|
|
174
|
-
_define_property(target, key, source[key]);
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
return target;
|
|
178
|
-
}
|
|
179
|
-
function Button_ownKeys(object, enumerableOnly) {
|
|
180
|
-
var keys = Object.keys(object);
|
|
181
|
-
if (Object.getOwnPropertySymbols) {
|
|
182
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
183
|
-
if (enumerableOnly) symbols = symbols.filter(function(sym) {
|
|
184
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
185
|
-
});
|
|
186
|
-
keys.push.apply(keys, symbols);
|
|
187
|
-
}
|
|
188
|
-
return keys;
|
|
189
|
-
}
|
|
190
|
-
function _object_spread_props(target, source) {
|
|
191
|
-
source = null != source ? source : {};
|
|
192
|
-
if (Object.getOwnPropertyDescriptors) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
193
|
-
else Button_ownKeys(Object(source)).forEach(function(key) {
|
|
194
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
195
|
-
});
|
|
196
|
-
return target;
|
|
197
|
-
}
|
|
198
|
-
function _object_without_properties(source, excluded) {
|
|
199
|
-
if (null == source) return {};
|
|
200
|
-
var target = {}, sourceKeys, key, i;
|
|
201
|
-
if ("u" > typeof Reflect && Reflect.ownKeys) {
|
|
202
|
-
sourceKeys = Reflect.ownKeys(Object(source));
|
|
203
|
-
for(i = 0; i < sourceKeys.length; i++){
|
|
204
|
-
key = sourceKeys[i];
|
|
205
|
-
if (!(excluded.indexOf(key) >= 0)) {
|
|
206
|
-
if (Object.prototype.propertyIsEnumerable.call(source, key)) target[key] = source[key];
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
return target;
|
|
210
|
-
}
|
|
211
|
-
target = _object_without_properties_loose(source, excluded);
|
|
212
|
-
if (Object.getOwnPropertySymbols) {
|
|
213
|
-
sourceKeys = Object.getOwnPropertySymbols(source);
|
|
214
|
-
for(i = 0; i < sourceKeys.length; i++){
|
|
215
|
-
key = sourceKeys[i];
|
|
216
|
-
if (!(excluded.indexOf(key) >= 0)) {
|
|
217
|
-
if (Object.prototype.propertyIsEnumerable.call(source, key)) target[key] = source[key];
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
return target;
|
|
222
|
-
}
|
|
223
|
-
function _object_without_properties_loose(source, excluded) {
|
|
224
|
-
if (null == source) return {};
|
|
225
|
-
var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
|
|
226
|
-
for(i = 0; i < sourceKeys.length; i++){
|
|
227
|
-
key = sourceKeys[i];
|
|
228
|
-
if (!(excluded.indexOf(key) >= 0)) {
|
|
229
|
-
if (Object.prototype.propertyIsEnumerable.call(source, key)) target[key] = source[key];
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
return target;
|
|
233
|
-
}
|
|
234
|
-
const Button = /*#__PURE__*/ (0, external_react_namespaceObject.forwardRef)((_0, _1)=>{
|
|
235
|
-
let _ref = [
|
|
236
|
-
_0,
|
|
237
|
-
_1
|
|
238
|
-
], [_ref1, ..._rest] = _ref, { children, variant, size, radius, loading = false, leadingIcon, trailingIcon, disabled = false, type = 'button', className } = _ref1, rest = _object_without_properties(_ref1, [
|
|
239
|
-
"children",
|
|
240
|
-
"variant",
|
|
241
|
-
"size",
|
|
242
|
-
"radius",
|
|
243
|
-
"loading",
|
|
244
|
-
"leadingIcon",
|
|
245
|
-
"trailingIcon",
|
|
246
|
-
"disabled",
|
|
247
|
-
"type",
|
|
248
|
-
"className"
|
|
249
|
-
]), [ref] = _rest;
|
|
250
|
-
const classes = className ? `${Button_css_button({
|
|
251
|
-
variant,
|
|
252
|
-
size,
|
|
253
|
-
radius
|
|
254
|
-
})} ${className}` : Button_css_button({
|
|
255
|
-
variant,
|
|
256
|
-
size,
|
|
257
|
-
radius
|
|
293
|
+
(()=>{
|
|
294
|
+
__webpack_require__.r(__webpack_exports__);
|
|
295
|
+
var _Button__rspack_import_0 = __webpack_require__(95);
|
|
296
|
+
const __rspack_default_export = _Button__rspack_import_0.A;
|
|
297
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
298
|
+
ButtonIcon: ()=>_Button__rspack_import_0.a
|
|
299
|
+
}, {
|
|
300
|
+
default: __rspack_default_export
|
|
258
301
|
});
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
type: type,
|
|
262
|
-
disabled: disabled || loading,
|
|
263
|
-
"aria-busy": loading || void 0,
|
|
264
|
-
className: classes
|
|
265
|
-
}, rest), {
|
|
266
|
-
children: [
|
|
267
|
-
loading ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(button_Spinner, {}) : leadingIcon,
|
|
268
|
-
children,
|
|
269
|
-
!loading && trailingIcon
|
|
270
|
-
]
|
|
271
|
-
}));
|
|
272
|
-
});
|
|
273
|
-
Button.displayName = 'Button';
|
|
274
|
-
const button_Button = Button;
|
|
275
|
-
const components_button = button_Button;
|
|
302
|
+
})();
|
|
303
|
+
exports.ButtonIcon = __webpack_exports__.ButtonIcon;
|
|
276
304
|
exports["default"] = __webpack_exports__["default"];
|
|
277
305
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
306
|
+
"ButtonIcon",
|
|
278
307
|
"default"
|
|
279
308
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
280
309
|
Object.defineProperty(exports, '__esModule', {
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __webpack_modules__ = {
|
|
3
|
-
|
|
3
|
+
95 (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
4
4
|
__webpack_require__.d(__webpack_exports__, {
|
|
5
|
-
|
|
5
|
+
a: ()=>ButtonIcon,
|
|
6
|
+
A: ()=>button_Button
|
|
6
7
|
});
|
|
7
8
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
9
|
+
const tokens_namespaceObject = require("@vinyasa/tokens");
|
|
8
10
|
const external_react_namespaceObject = require("react");
|
|
9
11
|
function toPrimitive(t, r) {
|
|
10
12
|
if ("object" != typeof t || !t) return t;
|
|
@@ -205,22 +207,24 @@ var __webpack_modules__ = {
|
|
|
205
207
|
}
|
|
206
208
|
return target;
|
|
207
209
|
}
|
|
210
|
+
const ButtonIcon = ({ children })=>children;
|
|
211
|
+
ButtonIcon.displayName = 'ButtonIcon';
|
|
212
|
+
const isButtonIcon = (node)=>/*#__PURE__*/ (0, external_react_namespaceObject.isValidElement)(node) && node.type === ButtonIcon;
|
|
208
213
|
const Button = /*#__PURE__*/ (0, external_react_namespaceObject.forwardRef)((_0, _1)=>{
|
|
209
214
|
let _ref = [
|
|
210
215
|
_0,
|
|
211
216
|
_1
|
|
212
|
-
], [_ref1, ..._rest] = _ref, { children, variant, size, radius, loading = false,
|
|
217
|
+
], [_ref1, ..._rest] = _ref, { children, variant, size, radius, loading = false, disabled = false, type = 'button', className } = _ref1, rest = _object_without_properties(_ref1, [
|
|
213
218
|
"children",
|
|
214
219
|
"variant",
|
|
215
220
|
"size",
|
|
216
221
|
"radius",
|
|
217
222
|
"loading",
|
|
218
|
-
"leadingIcon",
|
|
219
|
-
"trailingIcon",
|
|
220
223
|
"disabled",
|
|
221
224
|
"type",
|
|
222
225
|
"className"
|
|
223
226
|
]), [ref] = _rest;
|
|
227
|
+
const themedRef = (0, tokens_namespaceObject.useThemedRef)(ref);
|
|
224
228
|
const classes = className ? `${Button_css_button({
|
|
225
229
|
variant,
|
|
226
230
|
size,
|
|
@@ -230,23 +234,31 @@ var __webpack_modules__ = {
|
|
|
230
234
|
size,
|
|
231
235
|
radius
|
|
232
236
|
});
|
|
233
|
-
|
|
234
|
-
|
|
237
|
+
const childArray = external_react_namespaceObject.Children.toArray(children);
|
|
238
|
+
const hasLeadingIcon = isButtonIcon(childArray[0]);
|
|
239
|
+
const content = loading ? [
|
|
240
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(button_Spinner, {}, "spinner"),
|
|
241
|
+
...childArray.slice(hasLeadingIcon ? 1 : 0).filter((child)=>!isButtonIcon(child))
|
|
242
|
+
] : children;
|
|
243
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("button", _object_spread_props(_object_spread({
|
|
244
|
+
ref: themedRef,
|
|
235
245
|
type: type,
|
|
236
246
|
disabled: disabled || loading,
|
|
237
247
|
"aria-busy": loading || void 0,
|
|
238
248
|
className: classes
|
|
239
249
|
}, rest), {
|
|
240
|
-
children:
|
|
241
|
-
loading ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(button_Spinner, {}) : leadingIcon,
|
|
242
|
-
children,
|
|
243
|
-
!loading && trailingIcon
|
|
244
|
-
]
|
|
250
|
+
children: content
|
|
245
251
|
}));
|
|
246
252
|
});
|
|
247
253
|
Button.displayName = 'Button';
|
|
248
254
|
const button_Button = Button;
|
|
249
|
-
|
|
255
|
+
},
|
|
256
|
+
294 (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
257
|
+
var _Button__rspack_import_0 = __webpack_require__(95);
|
|
258
|
+
const __rspack_default_export = _Button__rspack_import_0.A;
|
|
259
|
+
__webpack_require__.d(__webpack_exports__, {}, {
|
|
260
|
+
default: __rspack_default_export
|
|
261
|
+
});
|
|
250
262
|
}
|
|
251
263
|
};
|
|
252
264
|
var __webpack_module_cache__ = {};
|
|
@@ -287,16 +299,20 @@ function __webpack_require__(moduleId) {
|
|
|
287
299
|
var __webpack_exports__ = {};
|
|
288
300
|
(()=>{
|
|
289
301
|
__webpack_require__.r(__webpack_exports__);
|
|
290
|
-
var _components_button__rspack_import_0 = __webpack_require__(
|
|
302
|
+
var _components_button__rspack_import_0 = __webpack_require__(294);
|
|
303
|
+
var _components_button__rspack_import_1 = __webpack_require__(95);
|
|
291
304
|
__webpack_require__.d(__webpack_exports__, {
|
|
292
305
|
Button: ()=>_components_button__rspack_import_0["default"],
|
|
306
|
+
ButtonIcon: ()=>_components_button__rspack_import_1.a,
|
|
293
307
|
default: ()=>_components_button__rspack_import_0["default"]
|
|
294
308
|
});
|
|
295
309
|
})();
|
|
296
310
|
exports.Button = __webpack_exports__.Button;
|
|
311
|
+
exports.ButtonIcon = __webpack_exports__.ButtonIcon;
|
|
297
312
|
exports["default"] = __webpack_exports__["default"];
|
|
298
313
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
299
314
|
"Button",
|
|
315
|
+
"ButtonIcon",
|
|
300
316
|
"default"
|
|
301
317
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
302
318
|
Object.defineProperty(exports, '__esModule', {
|
package/dist/esm/button.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import "./button.css";
|
|
2
|
-
import { jsx
|
|
3
|
-
import {
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useThemedRef } from "@vinyasa/tokens";
|
|
4
|
+
import { Children, forwardRef, isValidElement } from "react";
|
|
4
5
|
function toPrimitive(t, r) {
|
|
5
6
|
if ("object" != typeof t || !t) return t;
|
|
6
7
|
var e = t[Symbol.toPrimitive];
|
|
@@ -122,7 +123,11 @@ const Spinner = ()=>/*#__PURE__*/ jsx("span", {
|
|
|
122
123
|
"aria-hidden": "true"
|
|
123
124
|
});
|
|
124
125
|
const button_Spinner = Spinner;
|
|
125
|
-
const
|
|
126
|
+
const ButtonIcon = ({ children })=>children;
|
|
127
|
+
ButtonIcon.displayName = 'ButtonIcon';
|
|
128
|
+
const isButtonIcon = (node)=>/*#__PURE__*/ isValidElement(node) && node.type === ButtonIcon;
|
|
129
|
+
const Button = /*#__PURE__*/ forwardRef(({ children, variant, size, radius, loading = false, disabled = false, type = 'button', className, ...rest }, ref)=>{
|
|
130
|
+
const themedRef = useThemedRef(ref);
|
|
126
131
|
const classes = className ? `${Button_css_button({
|
|
127
132
|
variant,
|
|
128
133
|
size,
|
|
@@ -132,22 +137,24 @@ const Button = /*#__PURE__*/ forwardRef(({ children, variant, size, radius, load
|
|
|
132
137
|
size,
|
|
133
138
|
radius
|
|
134
139
|
});
|
|
135
|
-
|
|
136
|
-
|
|
140
|
+
const childArray = Children.toArray(children);
|
|
141
|
+
const hasLeadingIcon = isButtonIcon(childArray[0]);
|
|
142
|
+
const content = loading ? [
|
|
143
|
+
/*#__PURE__*/ jsx(button_Spinner, {}, "spinner"),
|
|
144
|
+
...childArray.slice(hasLeadingIcon ? 1 : 0).filter((child)=>!isButtonIcon(child))
|
|
145
|
+
] : children;
|
|
146
|
+
return /*#__PURE__*/ jsx("button", {
|
|
147
|
+
ref: themedRef,
|
|
137
148
|
type: type,
|
|
138
149
|
disabled: disabled || loading,
|
|
139
150
|
"aria-busy": loading || void 0,
|
|
140
151
|
className: classes,
|
|
141
152
|
...rest,
|
|
142
|
-
children:
|
|
143
|
-
loading ? /*#__PURE__*/ jsx(button_Spinner, {}) : leadingIcon,
|
|
144
|
-
children,
|
|
145
|
-
!loading && trailingIcon
|
|
146
|
-
]
|
|
153
|
+
children: content
|
|
147
154
|
});
|
|
148
155
|
});
|
|
149
156
|
Button.displayName = 'Button';
|
|
150
157
|
const button_Button = Button;
|
|
151
158
|
const components_button = button_Button;
|
|
152
159
|
export default components_button;
|
|
153
|
-
export { components_button as Button };
|
|
160
|
+
export { ButtonIcon, components_button as Button };
|
|
@@ -8,8 +8,13 @@ export interface ButtonProps extends Omit<ComponentPropsWithoutRef<'button'>, 'c
|
|
|
8
8
|
size?: ButtonSize;
|
|
9
9
|
radius?: ButtonRadius;
|
|
10
10
|
loading?: boolean;
|
|
11
|
-
leadingIcon?: ReactNode;
|
|
12
|
-
trailingIcon?: ReactNode;
|
|
13
11
|
}
|
|
12
|
+
export interface ButtonIconProps {
|
|
13
|
+
children: ReactNode;
|
|
14
|
+
}
|
|
15
|
+
export declare const ButtonIcon: {
|
|
16
|
+
({ children }: ButtonIconProps): ReactNode;
|
|
17
|
+
displayName: string;
|
|
18
|
+
};
|
|
14
19
|
declare const Button: import("react").ForwardRefExoticComponent<ButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
15
20
|
export default Button;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import Button from './Button';
|
|
1
|
+
import Button, { ButtonIcon } from './Button';
|
|
2
2
|
export default Button;
|
|
3
|
-
export
|
|
3
|
+
export { ButtonIcon };
|
|
4
|
+
export type { ButtonIconProps, ButtonProps, ButtonRadius, ButtonSize, ButtonVariant, } from './Button';
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { default as Button } from './components/button';
|
|
1
|
+
export { default as Button, ButtonIcon } from './components/button';
|
|
2
2
|
export { default } from './components/button';
|
|
3
|
-
export type { ButtonProps, ButtonRadius, ButtonSize, ButtonVariant } from './components/button';
|
|
3
|
+
export type { ButtonIconProps, ButtonProps, ButtonRadius, ButtonSize, ButtonVariant, } from './components/button';
|
package/dist/esm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Button, Button as default } from "./button.js";
|
|
1
|
+
export { Button, Button as default, ButtonIcon } from "./button.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vinyasa/button",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.24",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"react": "^18.0.0 || ^19.0.0",
|
|
43
43
|
"react-dom": "^18.0.0 || ^19.0.0",
|
|
44
|
-
"@vinyasa/tokens": "^1.0.
|
|
44
|
+
"@vinyasa/tokens": "^1.0.24"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@rsbuild/plugin-react": "^2.1.0",
|
|
@@ -54,9 +54,9 @@
|
|
|
54
54
|
"@vanilla-extract/vite-plugin": "^5.2.3",
|
|
55
55
|
"@vanilla-extract/webpack-plugin": "^2.3.27",
|
|
56
56
|
"typescript": "^5.7.3",
|
|
57
|
-
"@vinyasa/
|
|
58
|
-
"@vinyasa/
|
|
59
|
-
"@vinyasa/
|
|
57
|
+
"@vinyasa/icons": "1.0.24",
|
|
58
|
+
"@vinyasa/layout": "1.0.24",
|
|
59
|
+
"@vinyasa/tokens": "1.0.24"
|
|
60
60
|
},
|
|
61
61
|
"scripts": {
|
|
62
62
|
"build": "rslib build && node ../../scripts/postbuild-package.mjs",
|