@martinsura/ui 0.1.9 → 0.1.11

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 CHANGED
@@ -323,15 +323,18 @@ var buttonVariants = classVarianceAuthority.cva(
323
323
  {
324
324
  variants: {
325
325
  variant: {
326
- primary: "bg-(--ui-primary) text-(--ui-primary-text) hover:bg-(--ui-primary-hover) active:bg-(--ui-primary-active)",
327
- danger: "bg-(--ui-danger) text-(--ui-danger-text) hover:bg-(--ui-danger-hover) active:bg-(--ui-danger-hover)",
328
- success: "bg-(--ui-success) text-(--ui-success-text) hover:bg-(--ui-success-hover) active:bg-(--ui-success-hover)",
326
+ filled: "",
329
327
  default: "bg-white text-(--ui-text) border border-(--ui-border-strong) hover:bg-(--ui-surface-subtle) active:bg-(--ui-surface-muted)",
330
328
  subtle: "bg-(--ui-surface-subtle) text-(--ui-text) border border-transparent hover:bg-(--ui-surface-muted) active:bg-(--ui-surface-muted)",
331
329
  ghost: "text-(--ui-text) hover:bg-(--ui-surface-muted) active:bg-(--ui-surface-subtle)",
332
330
  text: "text-(--ui-text) hover:text-(--ui-text-strong) active:text-(--ui-text-strong) px-0! bg-transparent",
333
331
  link: "text-(--ui-primary) hover:underline p-0! h-auto!"
334
332
  },
333
+ color: {
334
+ primary: "",
335
+ success: "",
336
+ danger: ""
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)",
337
340
  middle: "h-(--ui-h-md) px-(--ui-px-md) [font-size:var(--ui-text-md)] rounded-(--ui-radius-md)",
@@ -347,8 +350,14 @@ var buttonVariants = classVarianceAuthority.cva(
347
350
  round: "rounded-full"
348
351
  }
349
352
  },
353
+ compoundVariants: [
354
+ { variant: "filled", color: "primary", class: "bg-(--ui-primary) text-(--ui-primary-text) hover:bg-(--ui-primary-hover) active:bg-(--ui-primary-active)" },
355
+ { variant: "filled", color: "success", class: "bg-(--ui-success) text-(--ui-success-text) hover:bg-(--ui-success-hover) active:bg-(--ui-success-hover)" },
356
+ { variant: "filled", color: "danger", class: "bg-(--ui-danger) text-(--ui-danger-text) hover:bg-(--ui-danger-hover) active:bg-(--ui-danger-hover)" }
357
+ ],
350
358
  defaultVariants: {
351
- variant: "primary",
359
+ variant: "filled",
360
+ color: "primary",
352
361
  size: "middle",
353
362
  block: false,
354
363
  shape: "default"
@@ -361,7 +370,8 @@ var iconSizeMap = {
361
370
  large: 18
362
371
  };
363
372
  var Button = ({
364
- variant = "primary",
373
+ variant = "filled",
374
+ color = "primary",
365
375
  size = "middle",
366
376
  shape = "default",
367
377
  block = false,
@@ -385,7 +395,7 @@ var Button = ({
385
395
  type: props.htmlType ?? "button",
386
396
  disabled: props.disabled || props.loading,
387
397
  className: tailwindMerge.twMerge(
388
- buttonVariants({ variant, size, block, shape }),
398
+ buttonVariants({ variant, color, size, block, shape }),
389
399
  fullWidthOnMobile && !block && "w-full sm:w-auto",
390
400
  props.iconOnly && "px-0!",
391
401
  props.className
@@ -421,6 +431,7 @@ var ConfirmButton = (props) => /* @__PURE__ */ jsxRuntime.jsx(
421
431
  disabled: props.disabled,
422
432
  loading: props.loading,
423
433
  variant: props.variant,
434
+ color: props.color,
424
435
  size: props.size,
425
436
  icon: props.icon,
426
437
  className: props.className,
@@ -532,8 +543,18 @@ var NumberInput = ({
532
543
  const resolvedErrors = props.errorName ? resolveError(props.errorName) : [];
533
544
  const errorDisplay = props.error ?? props.customError ?? (resolvedErrors.length > 0 ? resolvedErrors.join(", ") : void 0);
534
545
  const hasError = !!errorDisplay;
546
+ const [internalValue, setInternalValue] = react.useState(
547
+ props.value != null ? String(props.value) : ""
548
+ );
549
+ const isFocused = react.useRef(false);
550
+ react.useEffect(() => {
551
+ if (!isFocused.current) {
552
+ setInternalValue(props.value != null ? String(props.value) : "");
553
+ }
554
+ }, [props.value]);
535
555
  const handleChange = (e) => {
536
556
  const raw = e.target.value;
557
+ setInternalValue(raw);
537
558
  if (raw === "" || raw === "-") {
538
559
  props.onChange?.(null);
539
560
  return;
@@ -543,6 +564,13 @@ var NumberInput = ({
543
564
  props.onChange?.(num);
544
565
  }
545
566
  };
567
+ const handleFocus = () => {
568
+ isFocused.current = true;
569
+ };
570
+ const handleBlur = () => {
571
+ isFocused.current = false;
572
+ setInternalValue(props.value != null ? String(props.value) : "");
573
+ };
546
574
  return /* @__PURE__ */ jsxRuntime.jsxs(InputField, { noMargin: props.noMargin, className: props.className, children: [
547
575
  props.label && /* @__PURE__ */ jsxRuntime.jsx(
548
576
  InputLabel,
@@ -558,11 +586,13 @@ var NumberInput = ({
558
586
  {
559
587
  type: "number",
560
588
  placeholder: props.placeholder,
561
- value: props.value ?? "",
589
+ value: internalValue,
562
590
  disabled: props.disabled,
563
591
  min: props.min,
564
592
  max: props.max,
565
593
  onChange: handleChange,
594
+ onFocus: handleFocus,
595
+ onBlur: handleBlur,
566
596
  className: tailwindMerge.twMerge(
567
597
  numberInputClass,
568
598
  inputSizeClasses[size],