@martinsura/ui 0.1.10 → 0.1.12
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/index.cjs +52 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.cts +8 -3
- package/dist/index.d.ts +8 -3
- package/dist/index.js +52 -17
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -323,14 +323,17 @@ var buttonVariants = classVarianceAuthority.cva(
|
|
|
323
323
|
{
|
|
324
324
|
variants: {
|
|
325
325
|
variant: {
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
326
|
+
filled: "",
|
|
327
|
+
default: "bg-white border border-(--ui-border-strong) hover:bg-(--ui-surface-subtle) active:bg-(--ui-surface-muted)",
|
|
328
|
+
subtle: "bg-(--ui-surface-subtle) border border-transparent hover:bg-(--ui-surface-muted) active:bg-(--ui-surface-muted)",
|
|
329
|
+
ghost: "hover:bg-(--ui-surface-muted) active:bg-(--ui-surface-subtle)",
|
|
330
|
+
text: "px-0! bg-transparent",
|
|
331
|
+
link: "hover:underline p-0! h-auto!"
|
|
332
|
+
},
|
|
333
|
+
color: {
|
|
334
|
+
primary: "",
|
|
335
|
+
success: "",
|
|
336
|
+
danger: ""
|
|
334
337
|
},
|
|
335
338
|
size: {
|
|
336
339
|
small: "h-(--ui-h-sm) px-(--ui-px-sm) [font-size:var(--ui-text-sm)] rounded-(--ui-radius-sm)",
|
|
@@ -347,8 +350,35 @@ var buttonVariants = classVarianceAuthority.cva(
|
|
|
347
350
|
round: "rounded-full"
|
|
348
351
|
}
|
|
349
352
|
},
|
|
353
|
+
compoundVariants: [
|
|
354
|
+
// filled
|
|
355
|
+
{ variant: "filled", color: "primary", class: "bg-(--ui-primary) text-(--ui-primary-text) hover:bg-(--ui-primary-hover) active:bg-(--ui-primary-active)" },
|
|
356
|
+
{ variant: "filled", color: "success", class: "bg-(--ui-success) text-(--ui-success-text) hover:bg-(--ui-success-hover) active:bg-(--ui-success-hover)" },
|
|
357
|
+
{ variant: "filled", color: "danger", class: "bg-(--ui-danger) text-(--ui-danger-text) hover:bg-(--ui-danger-hover) active:bg-(--ui-danger-hover)" },
|
|
358
|
+
// default
|
|
359
|
+
{ variant: "default", color: "primary", class: "text-(--ui-text)" },
|
|
360
|
+
{ variant: "default", color: "success", class: "text-(--ui-success)" },
|
|
361
|
+
{ variant: "default", color: "danger", class: "text-(--ui-danger)" },
|
|
362
|
+
// subtle
|
|
363
|
+
{ variant: "subtle", color: "primary", class: "text-(--ui-text)" },
|
|
364
|
+
{ variant: "subtle", color: "success", class: "text-(--ui-success)" },
|
|
365
|
+
{ variant: "subtle", color: "danger", class: "text-(--ui-danger)" },
|
|
366
|
+
// ghost
|
|
367
|
+
{ variant: "ghost", color: "primary", class: "text-(--ui-text)" },
|
|
368
|
+
{ variant: "ghost", color: "success", class: "text-(--ui-success)" },
|
|
369
|
+
{ variant: "ghost", color: "danger", class: "text-(--ui-danger)" },
|
|
370
|
+
// text
|
|
371
|
+
{ variant: "text", color: "primary", class: "text-(--ui-text) hover:text-(--ui-text-strong) active:text-(--ui-text-strong)" },
|
|
372
|
+
{ variant: "text", color: "success", class: "text-(--ui-success)" },
|
|
373
|
+
{ variant: "text", color: "danger", class: "text-(--ui-danger)" },
|
|
374
|
+
// link
|
|
375
|
+
{ variant: "link", color: "primary", class: "text-(--ui-primary)" },
|
|
376
|
+
{ variant: "link", color: "success", class: "text-(--ui-success)" },
|
|
377
|
+
{ variant: "link", color: "danger", class: "text-(--ui-danger)" }
|
|
378
|
+
],
|
|
350
379
|
defaultVariants: {
|
|
351
|
-
variant: "
|
|
380
|
+
variant: "filled",
|
|
381
|
+
color: "primary",
|
|
352
382
|
size: "middle",
|
|
353
383
|
block: false,
|
|
354
384
|
shape: "default"
|
|
@@ -361,7 +391,8 @@ var iconSizeMap = {
|
|
|
361
391
|
large: 18
|
|
362
392
|
};
|
|
363
393
|
var Button = ({
|
|
364
|
-
variant = "
|
|
394
|
+
variant = "filled",
|
|
395
|
+
color = "primary",
|
|
365
396
|
size = "middle",
|
|
366
397
|
shape = "default",
|
|
367
398
|
block = false,
|
|
@@ -373,10 +404,13 @@ var Button = ({
|
|
|
373
404
|
const IconComponent = props.icon ?? (props.iconType ? getIcon(props.iconType) : void 0);
|
|
374
405
|
const iconNode = IconComponent ? /* @__PURE__ */ jsxRuntime.jsx(IconComponent, { size: iconSize, strokeWidth: 1.5, className: props.classNames?.icon }) : void 0;
|
|
375
406
|
const content = props.text ?? props.children;
|
|
376
|
-
const handleClick = () => {
|
|
377
|
-
if (props.
|
|
378
|
-
|
|
379
|
-
|
|
407
|
+
const handleClick = (e) => {
|
|
408
|
+
if (props.stopPropagation) e.stopPropagation();
|
|
409
|
+
if (props.disabled || props.loading) return;
|
|
410
|
+
props.onClick?.();
|
|
411
|
+
};
|
|
412
|
+
const handleConfirm = () => {
|
|
413
|
+
if (props.disabled || props.loading) return;
|
|
380
414
|
props.onClick?.();
|
|
381
415
|
};
|
|
382
416
|
const button = /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -385,12 +419,12 @@ var Button = ({
|
|
|
385
419
|
type: props.htmlType ?? "button",
|
|
386
420
|
disabled: props.disabled || props.loading,
|
|
387
421
|
className: tailwindMerge.twMerge(
|
|
388
|
-
buttonVariants({ variant, size, block, shape }),
|
|
422
|
+
buttonVariants({ variant, color, size, block, shape }),
|
|
389
423
|
fullWidthOnMobile && !block && "w-full sm:w-auto",
|
|
390
424
|
props.iconOnly && "px-0!",
|
|
391
425
|
props.className
|
|
392
426
|
),
|
|
393
|
-
onClick: props.confirm ? void 0 : handleClick,
|
|
427
|
+
onClick: props.confirm ? props.stopPropagation ? (e) => e.stopPropagation() : void 0 : handleClick,
|
|
394
428
|
children: [
|
|
395
429
|
props.loading ? /* @__PURE__ */ jsxRuntime.jsx(Spinner, { size: iconSize, color: "current", className: props.classNames?.spinner }) : iconPosition === "left" && iconNode,
|
|
396
430
|
!props.iconOnly && content !== void 0 && content !== null && /* @__PURE__ */ jsxRuntime.jsx("span", { className: props.classNames?.content, children: content }),
|
|
@@ -408,7 +442,7 @@ var Button = ({
|
|
|
408
442
|
confirmOk: props.confirm.confirmOk,
|
|
409
443
|
confirmCancel: props.confirm.confirmCancel,
|
|
410
444
|
confirmColor: props.confirm.confirmColor,
|
|
411
|
-
onConfirm:
|
|
445
|
+
onConfirm: handleConfirm,
|
|
412
446
|
children: button
|
|
413
447
|
}
|
|
414
448
|
);
|
|
@@ -421,6 +455,7 @@ var ConfirmButton = (props) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
|
421
455
|
disabled: props.disabled,
|
|
422
456
|
loading: props.loading,
|
|
423
457
|
variant: props.variant,
|
|
458
|
+
color: props.color,
|
|
424
459
|
size: props.size,
|
|
425
460
|
icon: props.icon,
|
|
426
461
|
className: props.className,
|