@blockle/blocks 0.8.2 → 0.8.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/index.cjs CHANGED
@@ -352,6 +352,23 @@ const useFocusLock = ({ ref, active }) => {
352
352
  };
353
353
  }, [active]);
354
354
  };
355
+ const useIsomorphicLayoutEffect = typeof window === "undefined" ? react.useEffect : react.useLayoutEffect;
356
+ const useKeyboard = (key, callback, { enabled = true, type = "keydown" } = {}) => {
357
+ react.useEffect(() => {
358
+ if (!enabled) {
359
+ return;
360
+ }
361
+ function handleKeyDown(event) {
362
+ if (event.key === key) {
363
+ callback();
364
+ }
365
+ }
366
+ document.addEventListener(type, handleKeyDown);
367
+ return () => {
368
+ document.removeEventListener(type, handleKeyDown);
369
+ };
370
+ }, [callback, enabled, key, type]);
371
+ };
355
372
  const useLayer = () => {
356
373
  const layerRef = react.useRef();
357
374
  react.useEffect(
@@ -372,7 +389,6 @@ const useLayer = () => {
372
389
  return layerRef.current;
373
390
  };
374
391
  };
375
- const useIsomorphicLayoutEffect = typeof window === "undefined" ? react.useEffect : react.useLayoutEffect;
376
392
  const usePreventBodyScroll = (enabled = true) => {
377
393
  useIsomorphicLayoutEffect(() => {
378
394
  if (!enabled) {
@@ -399,16 +415,18 @@ const usePreventBodyScroll = (enabled = true) => {
399
415
  };
400
416
  }, [enabled]);
401
417
  };
418
+ const isBrowser = typeof window !== "undefined";
402
419
  const useRestoreFocus = (active) => {
403
- const [target, setTarget] = react.useState(null);
404
- useIsomorphicLayoutEffect(() => {
405
- if (active && !target) {
406
- setTarget(document.activeElement);
407
- }
408
- }, [active]);
420
+ const target = react.useRef(null);
421
+ if (isBrowser && active && !target.current) {
422
+ target.current = document.activeElement;
423
+ }
409
424
  react.useEffect(() => {
410
- if (!active && target instanceof HTMLElement) {
411
- target.focus();
425
+ if (target.current && !active && target.current instanceof HTMLElement) {
426
+ target.current.focus();
427
+ }
428
+ if (!active) {
429
+ target.current = null;
412
430
  }
413
431
  }, [active]);
414
432
  };
@@ -424,6 +442,13 @@ const useVisibilityState = (open) => {
424
442
  }, [open]);
425
443
  return [visible, hide];
426
444
  };
445
+ function hasAnimationDuration(element) {
446
+ if (!element) {
447
+ return false;
448
+ }
449
+ const style = window.getComputedStyle(element);
450
+ return style.transitionDuration !== "0s" || style.animationDuration !== "0s";
451
+ }
427
452
  const Portal = ({ children, container }) => {
428
453
  const context = useTheme();
429
454
  return reactDom.createPortal(
@@ -453,6 +478,9 @@ const Dialog = ({
453
478
  size,
454
479
  ...restProps
455
480
  }) => {
481
+ const backdropClassName = useComponentStyles("dialog", { backdrop: true }, false);
482
+ const dialogClassName = useComponentStyles("dialog", { dialog: true, variants: { size } });
483
+ const backdropRef = react.useRef(null);
456
484
  const dialogRef = react.useRef(null);
457
485
  const layer = useLayer();
458
486
  const [visible, hide] = useVisibilityState(open);
@@ -465,55 +493,63 @@ const Dialog = ({
465
493
  },
466
494
  [onRequestClose]
467
495
  );
468
- const onAnimationEnd = react.useCallback((event) => {
469
- if (event.animationName === styles_components_Dialog_dialog_css_cjs.backdropLeaveAnimation) {
470
- event.stopPropagation();
471
- hide();
472
- }
473
- }, []);
474
496
  useFocusLock({ ref: dialogRef, active: open && enabled });
475
497
  useRestoreFocus(open);
476
498
  const isNested = useNestedDialog(visible);
477
499
  usePreventBodyScroll(visible && !isNested);
478
- react.useEffect(() => {
479
- if (!open || !enabled) {
500
+ useKeyboard("Escape", onRequestClose, { enabled: open && enabled });
501
+ useIsomorphicLayoutEffect(() => {
502
+ var _a, _b;
503
+ if (!open) {
504
+ (_a = backdropRef.current) == null ? void 0 : _a.removeAttribute("data-open");
505
+ (_b = dialogRef.current) == null ? void 0 : _b.removeAttribute("data-open");
480
506
  return;
481
507
  }
482
- const handleKeyDown = (event) => {
483
- if (event.key === "Escape") {
484
- onRequestClose();
485
- }
486
- };
487
- document.addEventListener("keydown", handleKeyDown);
508
+ let timer = requestAnimationFrame(() => {
509
+ timer = requestAnimationFrame(() => {
510
+ var _a2, _b2;
511
+ (_a2 = backdropRef.current) == null ? void 0 : _a2.setAttribute("data-open", "");
512
+ (_b2 = dialogRef.current) == null ? void 0 : _b2.setAttribute("data-open", "");
513
+ });
514
+ });
488
515
  return () => {
489
- document.removeEventListener("keydown", handleKeyDown);
516
+ cancelAnimationFrame(timer);
490
517
  };
491
- }, [open, enabled]);
492
- const backdropClassName = useComponentStyles("dialog", { backdrop: true }, false);
493
- const dialogClassName = useComponentStyles("dialog", { base: true, variants: { size } });
518
+ }, [open, visible]);
519
+ const onAnimationEnd = react.useCallback(() => {
520
+ if (!open) {
521
+ hide();
522
+ }
523
+ }, [hide, open]);
524
+ react.useEffect(() => {
525
+ if (open) {
526
+ return;
527
+ }
528
+ if (!hasAnimationDuration(dialogRef.current)) {
529
+ hide();
530
+ }
531
+ }, [open]);
494
532
  if (!visible) {
495
533
  return null;
496
534
  }
535
+ const dataOpen = typeof window === "undefined" && open ? "" : void 0;
497
536
  return /* @__PURE__ */ jsxRuntime.jsx(Portal, { container: layer(), children: /* @__PURE__ */ jsxRuntime.jsx(DialogContext.Provider, { value: { setEnabled }, children: /* @__PURE__ */ jsxRuntime.jsx(
498
537
  Box,
499
538
  {
500
- className: classnames(styles_components_Dialog_dialog_css_cjs.backdrop, !open && styles_components_Dialog_dialog_css_cjs.backdropLeave, backdropClassName),
501
- display: "flex",
502
- placeItems: "center",
539
+ ref: backdropRef,
540
+ className: classnames(styles_components_Dialog_dialog_css_cjs.backdrop, backdropClassName),
541
+ "data-open": dataOpen,
503
542
  onClick: onBackdropClick,
504
543
  onAnimationEnd,
544
+ onTransitionEnd: onAnimationEnd,
505
545
  children: /* @__PURE__ */ jsxRuntime.jsx(
506
546
  "dialog",
507
547
  {
508
548
  ref: dialogRef,
509
549
  "aria-modal": "true",
510
550
  open: true,
511
- className: classnames(
512
- styles_components_Dialog_dialog_css_cjs.dialog,
513
- !open && styles_components_Dialog_dialog_css_cjs.dialogLeave,
514
- dialogClassName,
515
- className
516
- ),
551
+ "data-open": dataOpen,
552
+ className: classnames(dialogClassName, className),
517
553
  ...restProps,
518
554
  children
519
555
  }
@@ -619,6 +655,44 @@ const Link = react.forwardRef(function Link2({ asChild, className, children, var
619
655
  }
620
656
  );
621
657
  });
658
+ const Progress = react.forwardRef(function Progress2({ value, max = 100, className, ...restProps }, ref) {
659
+ const containerClassName = useComponentStyles(
660
+ "progress",
661
+ {
662
+ container: true
663
+ },
664
+ false
665
+ );
666
+ const barClassName = useComponentStyles(
667
+ "progress",
668
+ { bar: true, variants: { indeterminate: value === void 0 } },
669
+ false
670
+ );
671
+ const progress = value === void 0 ? 0 : value / max * 100;
672
+ return /* @__PURE__ */ jsxRuntime.jsx(
673
+ Box,
674
+ {
675
+ ref,
676
+ className: classnames(containerClassName, className),
677
+ overflow: "hidden",
678
+ role: "progressbar",
679
+ "aria-valuenow": value,
680
+ "aria-valuemin": 0,
681
+ "aria-valuemax": max,
682
+ ...restProps,
683
+ children: /* @__PURE__ */ jsxRuntime.jsx(
684
+ Box,
685
+ {
686
+ className: classnames(barClassName),
687
+ backgroundColor: "currentColor",
688
+ width: "full",
689
+ height: "full",
690
+ style: { transform: value === void 0 ? void 0 : `translateX(-${100 - progress}%)` }
691
+ }
692
+ )
693
+ }
694
+ );
695
+ });
622
696
  const Radio = react.forwardRef(function Checkbox3({ name, label, className, ...restProps }, ref) {
623
697
  const containerClassName = useComponentStyles("radio", { base: true }, false);
624
698
  const iconClassName = useComponentStyles("radio", { icon: true }, false);
@@ -679,6 +753,7 @@ exports.Input = Input;
679
753
  exports.Label = Label;
680
754
  exports.Link = Link;
681
755
  exports.Portal = Portal;
756
+ exports.Progress = Progress;
682
757
  exports.Radio = Radio;
683
758
  exports.Slot = Slot;
684
759
  exports.Spinner = Spinner;
@@ -688,3 +763,6 @@ exports.classnames = classnames;
688
763
  exports.createSlottable = createSlottable;
689
764
  exports.useComponentStyleDefaultProps = useComponentStyleDefaultProps;
690
765
  exports.useComponentStyles = useComponentStyles;
766
+ exports.useIsomorphicLayoutEffect = useIsomorphicLayoutEffect;
767
+ exports.useKeyboard = useKeyboard;
768
+ exports.usePreventBodyScroll = usePreventBodyScroll;
package/dist/index.d.ts CHANGED
@@ -1 +1 @@
1
- export { BlocksProvider, BlocksProviderProps, Box, BoxProps, Button, ButtonProps, Checkbox, CheckboxProps, Dialog, DialogProps, Divider, DividerProps, Heading, HeadingProps, Inline, InlineProps, Input, InputProps, Label, LabelProps, Link, LinkProps, Portal, PortalProps, Radio, RadioProps, Slot, Spinner, SpinnerProps, Stack, StackProps, Text, TextProps, ThemeComponentsStyles, ThemeTokens, atoms, breakpointQuery, classnames, createSlottable, makeComponentTheme, makeTheme, useComponentStyleDefaultProps, useComponentStyles, vars } from './momotaro.chunk.js';
1
+ export { BlocksProvider, BlocksProviderProps, Box, BoxProps, Button, ButtonProps, Checkbox, CheckboxProps, Dialog, DialogProps, Divider, DividerProps, Heading, HeadingProps, Inline, InlineProps, Input, InputProps, Label, LabelProps, Link, LinkProps, Portal, PortalProps, Progress, ProgressProps, Radio, RadioProps, Slot, Spinner, SpinnerProps, Stack, StackProps, Text, TextProps, ThemeComponentsStyles, ThemeTokens, atoms, breakpointQuery, classnames, createSlottable, makeComponentTheme, makeTheme, useComponentStyleDefaultProps, useComponentStyles, useIsomorphicLayoutEffect, useKeyboard, usePreventBodyScroll, vars } from './momotaro.chunk.js';
package/dist/index.mjs CHANGED
@@ -6,10 +6,10 @@ import { makeTheme } from "./styles/lib/theme/makeTheme.mjs";
6
6
  import { vars } from "./styles/lib/theme/vars.css.mjs";
7
7
  import { atoms } from "./styles/lib/css/atoms/sprinkles.css.mjs";
8
8
  import { jsx, jsxs } from "react/jsx-runtime";
9
- import { createContext, forwardRef, Children, isValidElement, cloneElement, useContext, useEffect, useRef, useLayoutEffect, useState, useCallback, useId } from "react";
9
+ import { createContext, forwardRef, Children, isValidElement, cloneElement, useContext, useEffect, useLayoutEffect, useRef, useState, useCallback, useId } from "react";
10
10
  import { buttonReset } from "./styles/components/Button/Button.css.mjs";
11
11
  import { container, input, icon } from "./styles/components/Checkbox/checkbox.css.mjs";
12
- import { backdropLeaveAnimation, backdropLeave, backdrop, dialogLeave, dialog } from "./styles/components/Dialog/dialog.css.mjs";
12
+ import { backdrop } from "./styles/components/Dialog/dialog.css.mjs";
13
13
  import { createPortal } from "react-dom";
14
14
  import { divider } from "./styles/components/Divider/divider.css.mjs";
15
15
  import { heading } from "./styles/components/Heading/heading.css.mjs";
@@ -352,6 +352,23 @@ const useFocusLock = ({ ref, active }) => {
352
352
  };
353
353
  }, [active]);
354
354
  };
355
+ const useIsomorphicLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
356
+ const useKeyboard = (key, callback, { enabled = true, type = "keydown" } = {}) => {
357
+ useEffect(() => {
358
+ if (!enabled) {
359
+ return;
360
+ }
361
+ function handleKeyDown(event) {
362
+ if (event.key === key) {
363
+ callback();
364
+ }
365
+ }
366
+ document.addEventListener(type, handleKeyDown);
367
+ return () => {
368
+ document.removeEventListener(type, handleKeyDown);
369
+ };
370
+ }, [callback, enabled, key, type]);
371
+ };
355
372
  const useLayer = () => {
356
373
  const layerRef = useRef();
357
374
  useEffect(
@@ -372,7 +389,6 @@ const useLayer = () => {
372
389
  return layerRef.current;
373
390
  };
374
391
  };
375
- const useIsomorphicLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
376
392
  const usePreventBodyScroll = (enabled = true) => {
377
393
  useIsomorphicLayoutEffect(() => {
378
394
  if (!enabled) {
@@ -399,16 +415,18 @@ const usePreventBodyScroll = (enabled = true) => {
399
415
  };
400
416
  }, [enabled]);
401
417
  };
418
+ const isBrowser = typeof window !== "undefined";
402
419
  const useRestoreFocus = (active) => {
403
- const [target, setTarget] = useState(null);
404
- useIsomorphicLayoutEffect(() => {
405
- if (active && !target) {
406
- setTarget(document.activeElement);
407
- }
408
- }, [active]);
420
+ const target = useRef(null);
421
+ if (isBrowser && active && !target.current) {
422
+ target.current = document.activeElement;
423
+ }
409
424
  useEffect(() => {
410
- if (!active && target instanceof HTMLElement) {
411
- target.focus();
425
+ if (target.current && !active && target.current instanceof HTMLElement) {
426
+ target.current.focus();
427
+ }
428
+ if (!active) {
429
+ target.current = null;
412
430
  }
413
431
  }, [active]);
414
432
  };
@@ -424,6 +442,13 @@ const useVisibilityState = (open) => {
424
442
  }, [open]);
425
443
  return [visible, hide];
426
444
  };
445
+ function hasAnimationDuration(element) {
446
+ if (!element) {
447
+ return false;
448
+ }
449
+ const style = window.getComputedStyle(element);
450
+ return style.transitionDuration !== "0s" || style.animationDuration !== "0s";
451
+ }
427
452
  const Portal = ({ children, container: container2 }) => {
428
453
  const context = useTheme();
429
454
  return createPortal(
@@ -453,6 +478,9 @@ const Dialog = ({
453
478
  size,
454
479
  ...restProps
455
480
  }) => {
481
+ const backdropClassName = useComponentStyles("dialog", { backdrop: true }, false);
482
+ const dialogClassName = useComponentStyles("dialog", { dialog: true, variants: { size } });
483
+ const backdropRef = useRef(null);
456
484
  const dialogRef = useRef(null);
457
485
  const layer = useLayer();
458
486
  const [visible, hide] = useVisibilityState(open);
@@ -465,55 +493,63 @@ const Dialog = ({
465
493
  },
466
494
  [onRequestClose]
467
495
  );
468
- const onAnimationEnd = useCallback((event) => {
469
- if (event.animationName === backdropLeaveAnimation) {
470
- event.stopPropagation();
471
- hide();
472
- }
473
- }, []);
474
496
  useFocusLock({ ref: dialogRef, active: open && enabled });
475
497
  useRestoreFocus(open);
476
498
  const isNested = useNestedDialog(visible);
477
499
  usePreventBodyScroll(visible && !isNested);
478
- useEffect(() => {
479
- if (!open || !enabled) {
500
+ useKeyboard("Escape", onRequestClose, { enabled: open && enabled });
501
+ useIsomorphicLayoutEffect(() => {
502
+ var _a, _b;
503
+ if (!open) {
504
+ (_a = backdropRef.current) == null ? void 0 : _a.removeAttribute("data-open");
505
+ (_b = dialogRef.current) == null ? void 0 : _b.removeAttribute("data-open");
480
506
  return;
481
507
  }
482
- const handleKeyDown = (event) => {
483
- if (event.key === "Escape") {
484
- onRequestClose();
485
- }
486
- };
487
- document.addEventListener("keydown", handleKeyDown);
508
+ let timer = requestAnimationFrame(() => {
509
+ timer = requestAnimationFrame(() => {
510
+ var _a2, _b2;
511
+ (_a2 = backdropRef.current) == null ? void 0 : _a2.setAttribute("data-open", "");
512
+ (_b2 = dialogRef.current) == null ? void 0 : _b2.setAttribute("data-open", "");
513
+ });
514
+ });
488
515
  return () => {
489
- document.removeEventListener("keydown", handleKeyDown);
516
+ cancelAnimationFrame(timer);
490
517
  };
491
- }, [open, enabled]);
492
- const backdropClassName = useComponentStyles("dialog", { backdrop: true }, false);
493
- const dialogClassName = useComponentStyles("dialog", { base: true, variants: { size } });
518
+ }, [open, visible]);
519
+ const onAnimationEnd = useCallback(() => {
520
+ if (!open) {
521
+ hide();
522
+ }
523
+ }, [hide, open]);
524
+ useEffect(() => {
525
+ if (open) {
526
+ return;
527
+ }
528
+ if (!hasAnimationDuration(dialogRef.current)) {
529
+ hide();
530
+ }
531
+ }, [open]);
494
532
  if (!visible) {
495
533
  return null;
496
534
  }
535
+ const dataOpen = typeof window === "undefined" && open ? "" : void 0;
497
536
  return /* @__PURE__ */ jsx(Portal, { container: layer(), children: /* @__PURE__ */ jsx(DialogContext.Provider, { value: { setEnabled }, children: /* @__PURE__ */ jsx(
498
537
  Box,
499
538
  {
500
- className: classnames(backdrop, !open && backdropLeave, backdropClassName),
501
- display: "flex",
502
- placeItems: "center",
539
+ ref: backdropRef,
540
+ className: classnames(backdrop, backdropClassName),
541
+ "data-open": dataOpen,
503
542
  onClick: onBackdropClick,
504
543
  onAnimationEnd,
544
+ onTransitionEnd: onAnimationEnd,
505
545
  children: /* @__PURE__ */ jsx(
506
546
  "dialog",
507
547
  {
508
548
  ref: dialogRef,
509
549
  "aria-modal": "true",
510
550
  open: true,
511
- className: classnames(
512
- dialog,
513
- !open && dialogLeave,
514
- dialogClassName,
515
- className
516
- ),
551
+ "data-open": dataOpen,
552
+ className: classnames(dialogClassName, className),
517
553
  ...restProps,
518
554
  children
519
555
  }
@@ -619,6 +655,44 @@ const Link = forwardRef(function Link2({ asChild, className, children, variant,
619
655
  }
620
656
  );
621
657
  });
658
+ const Progress = forwardRef(function Progress2({ value, max = 100, className, ...restProps }, ref) {
659
+ const containerClassName = useComponentStyles(
660
+ "progress",
661
+ {
662
+ container: true
663
+ },
664
+ false
665
+ );
666
+ const barClassName = useComponentStyles(
667
+ "progress",
668
+ { bar: true, variants: { indeterminate: value === void 0 } },
669
+ false
670
+ );
671
+ const progress = value === void 0 ? 0 : value / max * 100;
672
+ return /* @__PURE__ */ jsx(
673
+ Box,
674
+ {
675
+ ref,
676
+ className: classnames(containerClassName, className),
677
+ overflow: "hidden",
678
+ role: "progressbar",
679
+ "aria-valuenow": value,
680
+ "aria-valuemin": 0,
681
+ "aria-valuemax": max,
682
+ ...restProps,
683
+ children: /* @__PURE__ */ jsx(
684
+ Box,
685
+ {
686
+ className: classnames(barClassName),
687
+ backgroundColor: "currentColor",
688
+ width: "full",
689
+ height: "full",
690
+ style: { transform: value === void 0 ? void 0 : `translateX(-${100 - progress}%)` }
691
+ }
692
+ )
693
+ }
694
+ );
695
+ });
622
696
  const Radio = forwardRef(function Checkbox3({ name, label, className, ...restProps }, ref) {
623
697
  const containerClassName = useComponentStyles("radio", { base: true }, false);
624
698
  const iconClassName = useComponentStyles("radio", { icon: true }, false);
@@ -675,6 +749,7 @@ export {
675
749
  Label,
676
750
  Link,
677
751
  Portal,
752
+ Progress,
678
753
  Radio,
679
754
  Slot,
680
755
  Spinner,
@@ -688,5 +763,8 @@ export {
688
763
  makeTheme,
689
764
  useComponentStyleDefaultProps,
690
765
  useComponentStyles,
766
+ useIsomorphicLayoutEffect,
767
+ useKeyboard,
768
+ usePreventBodyScroll,
691
769
  vars
692
770
  };
@@ -1,6 +1,6 @@
1
1
  import * as _vanilla_extract_sprinkles from '@vanilla-extract/sprinkles';
2
2
  import * as react from 'react';
3
- import react__default from 'react';
3
+ import react__default, { useEffect } from 'react';
4
4
 
5
5
  declare const atoms: ((props: {
6
6
  readonly backgroundColor?: "link" | "white" | "black" | "body" | "primaryLight" | "primary" | "primaryDark" | "secondaryLight" | "secondary" | "secondaryDark" | "text" | "textLight" | "textDark" | "danger" | "currentColor" | undefined;
@@ -316,8 +316,8 @@ type DividerTheme = {
316
316
  };
317
317
  };
318
318
  type DialogTheme = {
319
- base: string;
320
319
  backdrop: string;
320
+ dialog: string;
321
321
  variants: {
322
322
  size: 'small' | 'medium' | 'large';
323
323
  };
@@ -351,6 +351,13 @@ type LabelTheme = {
351
351
  required: boolean;
352
352
  };
353
353
  };
354
+ type ProgressTheme = {
355
+ container: string;
356
+ bar: string;
357
+ variants: {
358
+ indeterminate: boolean;
359
+ };
360
+ };
354
361
  type ComponentThemes = {
355
362
  button: ButtonTheme;
356
363
  link: LinkTheme;
@@ -361,6 +368,7 @@ type ComponentThemes = {
361
368
  checkbox: CheckboxTheme;
362
369
  radio: RadioTheme;
363
370
  label: LabelTheme;
371
+ progress: ProgressTheme;
364
372
  };
365
373
  /**
366
374
  * ComponentThemeProps is a helper type to define the props passed to useComponentStyles.
@@ -931,6 +939,19 @@ type PortalProps = {
931
939
  };
932
940
  declare const Portal: React.FC<PortalProps>;
933
941
 
942
+ type ProgressProps = {
943
+ /**
944
+ * The value of the progress bar, between 0 and 100.
945
+ * If undefined, the progress bar will be indeterminate.
946
+ */
947
+ value?: number;
948
+ max?: number;
949
+ className?: string;
950
+ style?: React.CSSProperties;
951
+ 'aria-labelledby'?: string;
952
+ };
953
+ declare const Progress: react.ForwardRefExoticComponent<ProgressProps & react.RefAttributes<HTMLProgressElement>>;
954
+
934
955
  type RadioProps = {
935
956
  name: string;
936
957
  value: string;
@@ -968,7 +989,7 @@ declare const Stack: React.FC<StackProps>;
968
989
 
969
990
  type TextProps = {
970
991
  children: React.ReactNode;
971
- tag?: 'span' | 'p' | 'strong' | 'em' | 'small' | 's' | 'del' | 'ins' | 'sub' | 'sup';
992
+ tag?: 'span' | 'p' | 'strong' | 'em' | 'small' | 's' | 'del' | 'ins' | 'sub' | 'sup' | 'label';
972
993
  asChild?: boolean;
973
994
  } & TextAtoms & MarginAtoms & PaddingAtoms & HTMLElementProps<HTMLSpanElement>;
974
995
  declare const Text: React.FC<TextProps>;
@@ -996,9 +1017,22 @@ type Components = {
996
1017
  };
997
1018
  declare const useComponentStyleDefaultProps: <T extends keyof ComponentThemes>(name: T) => Components[T];
998
1019
 
1020
+ /**
1021
+ * useLayoutEffect is not avaible on server side use useEffect instead.
1022
+ */
1023
+ declare const useIsomorphicLayoutEffect: typeof useEffect;
1024
+
1025
+ type UseKeyboardOptions = {
1026
+ enabled?: boolean;
1027
+ type?: 'keydown' | 'keyup';
1028
+ };
1029
+ declare const useKeyboard: (key: string, callback: () => void, { enabled, type }?: UseKeyboardOptions) => void;
1030
+
1031
+ declare const usePreventBodyScroll: (enabled?: boolean) => void;
1032
+
999
1033
  type Args = null | undefined | boolean | string;
1000
1034
  declare const classnames: (...args: Args[]) => string | undefined;
1001
1035
 
1002
1036
  declare const momotaro: Theme;
1003
1037
 
1004
- export { BlocksProvider, BlocksProviderProps, Box, BoxProps, Button, ButtonProps, Checkbox, CheckboxProps, Dialog, DialogProps, Divider, DividerProps, Heading, HeadingProps, Inline, InlineProps, Input, InputProps, Label, LabelProps, Link, LinkProps, Portal, PortalProps, Radio, RadioProps, Slot, Spinner, SpinnerProps, Stack, StackProps, Text, TextProps, ThemeComponentsStyles, ThemeTokens, atoms, breakpointQuery, classnames, createSlottable, makeComponentTheme, makeTheme, momotaro, useComponentStyleDefaultProps, useComponentStyles, vars };
1038
+ export { BlocksProvider, BlocksProviderProps, Box, BoxProps, Button, ButtonProps, Checkbox, CheckboxProps, Dialog, DialogProps, Divider, DividerProps, Heading, HeadingProps, Inline, InlineProps, Input, InputProps, Label, LabelProps, Link, LinkProps, Portal, PortalProps, Progress, ProgressProps, Radio, RadioProps, Slot, Spinner, SpinnerProps, Stack, StackProps, Text, TextProps, ThemeComponentsStyles, ThemeTokens, atoms, breakpointQuery, classnames, createSlottable, makeComponentTheme, makeTheme, momotaro, useComponentStyleDefaultProps, useComponentStyles, useIsomorphicLayoutEffect, useKeyboard, usePreventBodyScroll, vars };
@@ -3,81 +3,20 @@ const fileScope = require("@vanilla-extract/css/fileScope");
3
3
  const css = require("@vanilla-extract/css");
4
4
  const styles_lib_css_layers_layers_css_cjs = require("../../lib/css/layers/layers.css.cjs");
5
5
  fileScope.setFileScope("src/components/Dialog/dialog.css.ts?used", "blocks");
6
- const backdropEnterAnimation = css.keyframes({
7
- "0%": {
8
- opacity: 0
9
- },
10
- "100%": {
11
- opacity: 1
12
- }
13
- }, "backdropEnterAnimation");
14
- const backdropLeaveAnimation = css.keyframes({
15
- "0%": {
16
- opacity: 1
17
- },
18
- "100%": {
19
- opacity: 0
20
- }
21
- }, "backdropLeaveAnimation");
22
- const dialogEnterAnimation = css.keyframes({
23
- "0%": {
24
- transform: "translateY(-34px)"
25
- },
26
- "100%": {
27
- transform: "translateY(0)"
28
- }
29
- }, "dialogEnterAnimation");
30
- const dialogLeaveAnimation = css.keyframes({
31
- "0%": {
32
- transform: "translateY(0)"
33
- },
34
- "100%": {
35
- transform: "translateY(-34px)"
36
- }
37
- }, "dialogLeaveAnimation");
38
6
  const backdrop = css.style({
39
7
  "@layer": {
40
8
  [styles_lib_css_layers_layers_css_cjs.blocksLayer]: {
41
9
  contain: "layout",
10
+ display: "flex",
11
+ placeItems: "center",
42
12
  position: "fixed",
43
13
  width: "100%",
44
14
  height: "100%",
45
15
  left: 0,
46
16
  top: 0,
47
- overflow: "hidden",
48
- opacity: "0",
49
- animationName: backdropEnterAnimation,
50
- animationDuration: "100ms",
51
- animationFillMode: "both"
17
+ overflow: "hidden"
52
18
  }
53
19
  }
54
20
  }, "backdrop");
55
- const backdropLeave = css.style({
56
- "@layer": {
57
- [styles_lib_css_layers_layers_css_cjs.blocksLayer]: {
58
- animationName: backdropLeaveAnimation
59
- }
60
- }
61
- }, "backdropLeave");
62
- const dialog = css.style({
63
- "@layer": {
64
- [styles_lib_css_layers_layers_css_cjs.blocksLayer]: {
65
- animationName: dialogEnterAnimation,
66
- animationDuration: "160ms",
67
- animationFillMode: "both"
68
- }
69
- }
70
- }, "dialog");
71
- const dialogLeave = css.style({
72
- "@layer": {
73
- [styles_lib_css_layers_layers_css_cjs.blocksLayer]: {
74
- animationName: dialogLeaveAnimation
75
- }
76
- }
77
- }, "dialogLeave");
78
21
  fileScope.endFileScope();
79
22
  exports.backdrop = backdrop;
80
- exports.backdropLeave = backdropLeave;
81
- exports.backdropLeaveAnimation = backdropLeaveAnimation;
82
- exports.dialog = dialog;
83
- exports.dialogLeave = dialogLeave;
@@ -1,84 +1,23 @@
1
1
  import { setFileScope, endFileScope } from "@vanilla-extract/css/fileScope";
2
- import { keyframes, style } from "@vanilla-extract/css";
2
+ import { style } from "@vanilla-extract/css";
3
3
  import { blocksLayer } from "../../lib/css/layers/layers.css.mjs";
4
4
  setFileScope("src/components/Dialog/dialog.css.ts?used", "blocks");
5
- const backdropEnterAnimation = keyframes({
6
- "0%": {
7
- opacity: 0
8
- },
9
- "100%": {
10
- opacity: 1
11
- }
12
- }, "backdropEnterAnimation");
13
- const backdropLeaveAnimation = keyframes({
14
- "0%": {
15
- opacity: 1
16
- },
17
- "100%": {
18
- opacity: 0
19
- }
20
- }, "backdropLeaveAnimation");
21
- const dialogEnterAnimation = keyframes({
22
- "0%": {
23
- transform: "translateY(-34px)"
24
- },
25
- "100%": {
26
- transform: "translateY(0)"
27
- }
28
- }, "dialogEnterAnimation");
29
- const dialogLeaveAnimation = keyframes({
30
- "0%": {
31
- transform: "translateY(0)"
32
- },
33
- "100%": {
34
- transform: "translateY(-34px)"
35
- }
36
- }, "dialogLeaveAnimation");
37
5
  const backdrop = style({
38
6
  "@layer": {
39
7
  [blocksLayer]: {
40
8
  contain: "layout",
9
+ display: "flex",
10
+ placeItems: "center",
41
11
  position: "fixed",
42
12
  width: "100%",
43
13
  height: "100%",
44
14
  left: 0,
45
15
  top: 0,
46
- overflow: "hidden",
47
- opacity: "0",
48
- animationName: backdropEnterAnimation,
49
- animationDuration: "100ms",
50
- animationFillMode: "both"
16
+ overflow: "hidden"
51
17
  }
52
18
  }
53
19
  }, "backdrop");
54
- const backdropLeave = style({
55
- "@layer": {
56
- [blocksLayer]: {
57
- animationName: backdropLeaveAnimation
58
- }
59
- }
60
- }, "backdropLeave");
61
- const dialog = style({
62
- "@layer": {
63
- [blocksLayer]: {
64
- animationName: dialogEnterAnimation,
65
- animationDuration: "160ms",
66
- animationFillMode: "both"
67
- }
68
- }
69
- }, "dialog");
70
- const dialogLeave = style({
71
- "@layer": {
72
- [blocksLayer]: {
73
- animationName: dialogLeaveAnimation
74
- }
75
- }
76
- }, "dialogLeave");
77
20
  endFileScope();
78
21
  export {
79
- backdrop,
80
- backdropLeave,
81
- backdropLeaveAnimation,
82
- dialog,
83
- dialogLeave
22
+ backdrop
84
23
  };
@@ -6,7 +6,12 @@ fileScope.setFileScope("src/components/Input/input.css.ts?used", "blocks");
6
6
  const input = css.style({
7
7
  "@layer": {
8
8
  [styles_lib_css_layers_layers_css_cjs.blocksLayer]: {
9
- appearance: "none"
9
+ appearance: "none",
10
+ selectors: {
11
+ "&:-webkit-autofill": {
12
+ transitionDelay: "9999s"
13
+ }
14
+ }
10
15
  }
11
16
  }
12
17
  }, "input");
@@ -5,7 +5,12 @@ setFileScope("src/components/Input/input.css.ts?used", "blocks");
5
5
  const input = style({
6
6
  "@layer": {
7
7
  [blocksLayer]: {
8
- appearance: "none"
8
+ appearance: "none",
9
+ selectors: {
10
+ "&:-webkit-autofill": {
11
+ transitionDelay: "9999s"
12
+ }
13
+ }
9
14
  }
10
15
  }
11
16
  }, "input");
@@ -5,7 +5,7 @@ const styles_lib_theme_makeComponentTheme_cjs = require("../../../lib/theme/make
5
5
  const styles_lib_css_atoms_sprinkles_css_cjs = require("../../../lib/css/atoms/sprinkles.css.cjs");
6
6
  fileScope.setFileScope("src/themes/momotaro/components/dialog.css.ts?used", "blocks");
7
7
  const dialog = styles_lib_theme_makeComponentTheme_cjs.makeComponentTheme("dialog", {
8
- base: css.style([styles_lib_css_atoms_sprinkles_css_cjs.atoms({
8
+ dialog: css.style([styles_lib_css_atoms_sprinkles_css_cjs.atoms({
9
9
  display: "flex",
10
10
  flexDirection: "column",
11
11
  padding: "gutter",
@@ -14,10 +14,34 @@ const dialog = styles_lib_theme_makeComponentTheme_cjs.makeComponentTheme("dialo
14
14
  borderRadius: "medium",
15
15
  boxShadow: "large"
16
16
  }), {
17
- minWidth: "300px"
18
- }], "dialog_base"),
17
+ minWidth: "300px",
18
+ selectors: {
19
+ "&[data-open]": {
20
+ transform: "scale(1)"
21
+ }
22
+ },
23
+ // Apply the animation only if the user has not requested reduced motion
24
+ "@media": {
25
+ "(prefers-reduced-motion: no-preference)": {
26
+ transform: "scale(0.9)",
27
+ transition: "transform 160ms"
28
+ }
29
+ }
30
+ }], "dialog_dialog"),
19
31
  backdrop: css.style({
20
- backgroundColor: "rgba(0, 0, 0, 0.5)"
32
+ backgroundColor: "rgba(0, 0, 0, 0.5)",
33
+ selectors: {
34
+ "&[data-open]": {
35
+ opacity: 1
36
+ }
37
+ },
38
+ // Apply the animation only if the user has not requested reduced motion
39
+ "@media": {
40
+ "(prefers-reduced-motion: no-preference)": {
41
+ opacity: 0,
42
+ transition: "opacity 160ms"
43
+ }
44
+ }
21
45
  }, "dialog_backdrop"),
22
46
  variants: {
23
47
  size: {
@@ -4,7 +4,7 @@ import { makeComponentTheme } from "../../../lib/theme/makeComponentTheme.mjs";
4
4
  import { atoms } from "../../../lib/css/atoms/sprinkles.css.mjs";
5
5
  setFileScope("src/themes/momotaro/components/dialog.css.ts?used", "blocks");
6
6
  const dialog = makeComponentTheme("dialog", {
7
- base: style([atoms({
7
+ dialog: style([atoms({
8
8
  display: "flex",
9
9
  flexDirection: "column",
10
10
  padding: "gutter",
@@ -13,10 +13,34 @@ const dialog = makeComponentTheme("dialog", {
13
13
  borderRadius: "medium",
14
14
  boxShadow: "large"
15
15
  }), {
16
- minWidth: "300px"
17
- }], "dialog_base"),
16
+ minWidth: "300px",
17
+ selectors: {
18
+ "&[data-open]": {
19
+ transform: "scale(1)"
20
+ }
21
+ },
22
+ // Apply the animation only if the user has not requested reduced motion
23
+ "@media": {
24
+ "(prefers-reduced-motion: no-preference)": {
25
+ transform: "scale(0.9)",
26
+ transition: "transform 160ms"
27
+ }
28
+ }
29
+ }], "dialog_dialog"),
18
30
  backdrop: style({
19
- backgroundColor: "rgba(0, 0, 0, 0.5)"
31
+ backgroundColor: "rgba(0, 0, 0, 0.5)",
32
+ selectors: {
33
+ "&[data-open]": {
34
+ opacity: 1
35
+ }
36
+ },
37
+ // Apply the animation only if the user has not requested reduced motion
38
+ "@media": {
39
+ "(prefers-reduced-motion: no-preference)": {
40
+ opacity: 0,
41
+ transition: "opacity 160ms"
42
+ }
43
+ }
20
44
  }, "dialog_backdrop"),
21
45
  variants: {
22
46
  size: {
@@ -6,17 +6,19 @@ const styles_themes_momotaro_components_divider_css_cjs = require("./divider.css
6
6
  const styles_themes_momotaro_components_input_css_cjs = require("./input.css.cjs");
7
7
  const styles_themes_momotaro_components_label_css_cjs = require("./label.css.cjs");
8
8
  const styles_themes_momotaro_components_link_css_cjs = require("./link.css.cjs");
9
+ const styles_themes_momotaro_components_progress_css_cjs = require("./progress.css.cjs");
9
10
  const styles_themes_momotaro_components_radio_css_cjs = require("./radio.css.cjs");
10
11
  const styles_themes_momotaro_components_spinner_css_cjs = require("./spinner.css.cjs");
11
12
  const components = {
12
13
  button: styles_themes_momotaro_components_button_css_cjs.button,
13
- link: styles_themes_momotaro_components_link_css_cjs.link,
14
- spinner: styles_themes_momotaro_components_spinner_css_cjs.spinner,
15
- divider: styles_themes_momotaro_components_divider_css_cjs.divider,
14
+ checkbox: styles_themes_momotaro_components_checkbox_css_cjs.checkbox,
16
15
  dialog: styles_themes_momotaro_components_dialog_css_cjs.dialog,
16
+ divider: styles_themes_momotaro_components_divider_css_cjs.divider,
17
17
  input: styles_themes_momotaro_components_input_css_cjs.input,
18
- checkbox: styles_themes_momotaro_components_checkbox_css_cjs.checkbox,
18
+ label: styles_themes_momotaro_components_label_css_cjs.label,
19
+ link: styles_themes_momotaro_components_link_css_cjs.link,
20
+ progress: styles_themes_momotaro_components_progress_css_cjs.progress,
19
21
  radio: styles_themes_momotaro_components_radio_css_cjs.radio,
20
- label: styles_themes_momotaro_components_label_css_cjs.label
22
+ spinner: styles_themes_momotaro_components_spinner_css_cjs.spinner
21
23
  };
22
24
  exports.components = components;
@@ -5,18 +5,20 @@ import { divider } from "./divider.css.mjs";
5
5
  import { input } from "./input.css.mjs";
6
6
  import { label } from "./label.css.mjs";
7
7
  import { link } from "./link.css.mjs";
8
+ import { progress } from "./progress.css.mjs";
8
9
  import { radio } from "./radio.css.mjs";
9
10
  import { spinner } from "./spinner.css.mjs";
10
11
  const components = {
11
12
  button,
12
- link,
13
- spinner,
14
- divider,
13
+ checkbox,
15
14
  dialog,
15
+ divider,
16
16
  input,
17
- checkbox,
17
+ label,
18
+ link,
19
+ progress,
18
20
  radio,
19
- label
21
+ spinner
20
22
  };
21
23
  export {
22
24
  components
@@ -32,8 +32,7 @@ const input = styles_lib_theme_makeComponentTheme_cjs.makeComponentTheme("input"
32
32
  }, styles_lib_css_atoms_sprinkles_css_cjs.atoms({
33
33
  backgroundColor: "white",
34
34
  borderRadius: "medium",
35
- boxShadow: "medium",
36
- gap: "large"
35
+ boxShadow: "medium"
37
36
  })], "input_container")
38
37
  });
39
38
  fileScope.endFileScope();
@@ -31,8 +31,7 @@ const input = makeComponentTheme("input", {
31
31
  }, atoms({
32
32
  backgroundColor: "white",
33
33
  borderRadius: "medium",
34
- boxShadow: "medium",
35
- gap: "large"
34
+ boxShadow: "medium"
36
35
  })], "input_container")
37
36
  });
38
37
  endFileScope();
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ const fileScope = require("@vanilla-extract/css/fileScope");
3
+ const css = require("@vanilla-extract/css");
4
+ const styles_lib_theme_makeComponentTheme_cjs = require("../../../lib/theme/makeComponentTheme.cjs");
5
+ const styles_lib_css_atoms_sprinkles_css_cjs = require("../../../lib/css/atoms/sprinkles.css.cjs");
6
+ fileScope.setFileScope("src/themes/momotaro/components/progress.css.ts?used", "blocks");
7
+ const indeterminateAnimation = css.keyframes({
8
+ "0%": {
9
+ transform: "translateX(-100%)"
10
+ },
11
+ "100%": {
12
+ transform: "translateX(100%)"
13
+ }
14
+ }, "indeterminateAnimation");
15
+ const progress = styles_lib_theme_makeComponentTheme_cjs.makeComponentTheme("progress", {
16
+ container: css.style([{
17
+ height: 6
18
+ }, styles_lib_css_atoms_sprinkles_css_cjs.atoms({
19
+ width: "full",
20
+ borderRadius: "small",
21
+ backgroundColor: "textLight",
22
+ color: "primary",
23
+ overflow: "hidden"
24
+ })], "progress_container"),
25
+ bar: css.style({
26
+ borderRadius: "inherit",
27
+ "@media": {
28
+ "(prefers-reduced-motion: no-preference)": {
29
+ transition: "transform 180ms ease-out"
30
+ }
31
+ }
32
+ }, "progress_bar"),
33
+ variants: {
34
+ indeterminate: css.style({
35
+ animation: `${indeterminateAnimation} 10s ease-in-out infinite`,
36
+ "@media": {
37
+ "(prefers-reduced-motion: no-preference)": {
38
+ animationDuration: "3s"
39
+ }
40
+ }
41
+ }, "progress_variants_indeterminate")
42
+ }
43
+ });
44
+ fileScope.endFileScope();
45
+ exports.progress = progress;
@@ -0,0 +1,46 @@
1
+ import { setFileScope, endFileScope } from "@vanilla-extract/css/fileScope";
2
+ import { keyframes, style } from "@vanilla-extract/css";
3
+ import { makeComponentTheme } from "../../../lib/theme/makeComponentTheme.mjs";
4
+ import { atoms } from "../../../lib/css/atoms/sprinkles.css.mjs";
5
+ setFileScope("src/themes/momotaro/components/progress.css.ts?used", "blocks");
6
+ const indeterminateAnimation = keyframes({
7
+ "0%": {
8
+ transform: "translateX(-100%)"
9
+ },
10
+ "100%": {
11
+ transform: "translateX(100%)"
12
+ }
13
+ }, "indeterminateAnimation");
14
+ const progress = makeComponentTheme("progress", {
15
+ container: style([{
16
+ height: 6
17
+ }, atoms({
18
+ width: "full",
19
+ borderRadius: "small",
20
+ backgroundColor: "textLight",
21
+ color: "primary",
22
+ overflow: "hidden"
23
+ })], "progress_container"),
24
+ bar: style({
25
+ borderRadius: "inherit",
26
+ "@media": {
27
+ "(prefers-reduced-motion: no-preference)": {
28
+ transition: "transform 180ms ease-out"
29
+ }
30
+ }
31
+ }, "progress_bar"),
32
+ variants: {
33
+ indeterminate: style({
34
+ animation: `${indeterminateAnimation} 10s ease-in-out infinite`,
35
+ "@media": {
36
+ "(prefers-reduced-motion: no-preference)": {
37
+ animationDuration: "3s"
38
+ }
39
+ }
40
+ }, "progress_variants_indeterminate")
41
+ }
42
+ });
43
+ endFileScope();
44
+ export {
45
+ progress
46
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blockle/blocks",
3
- "version": "0.8.2",
3
+ "version": "0.8.4",
4
4
  "description": "Blocks design system",
5
5
  "repository": "git@github.com:Blockle/blocks.git",
6
6
  "license": "MIT",
@@ -60,37 +60,37 @@
60
60
  "@changesets/cli": "^2.26.2",
61
61
  "@crackle/cli": "^0.12.4",
62
62
  "@crackle/core": "^0.28.0",
63
- "@storybook/addon-a11y": "^7.3.1",
63
+ "@storybook/addon-a11y": "^7.5.2",
64
64
  "@storybook/addon-coverage": "^0.0.9",
65
- "@storybook/addon-essentials": "^7.3.1",
66
- "@storybook/addon-interactions": "^7.3.1",
67
- "@storybook/addon-links": "^7.3.1",
68
- "@storybook/blocks": "^7.3.1",
69
- "@storybook/jest": "^0.2.0",
70
- "@storybook/react": "^7.3.1",
71
- "@storybook/react-vite": "^7.3.1",
72
- "@storybook/testing-library": "^0.2.0",
65
+ "@storybook/addon-essentials": "^7.5.2",
66
+ "@storybook/addon-interactions": "^7.5.2",
67
+ "@storybook/addon-links": "^7.5.2",
68
+ "@storybook/blocks": "^7.5.2",
69
+ "@storybook/jest": "^0.2.3",
70
+ "@storybook/react": "^7.5.2",
71
+ "@storybook/react-vite": "^7.5.2",
72
+ "@storybook/testing-library": "^0.2.2",
73
73
  "@testing-library/jest-dom": "^6.1.4",
74
74
  "@testing-library/react": "^14.0.0",
75
- "@types/react": "^18.2.28",
76
- "@types/react-dom": "^18.2.13",
77
- "@typescript-eslint/eslint-plugin": "^6.8.0",
78
- "@typescript-eslint/parser": "^6.8.0",
75
+ "@types/react": "^18.2.34",
76
+ "@types/react-dom": "^18.2.14",
77
+ "@typescript-eslint/eslint-plugin": "^6.9.1",
78
+ "@typescript-eslint/parser": "^6.9.1",
79
79
  "@vanilla-extract/vite-plugin": "^3.8.2",
80
80
  "@vitest/coverage-v8": "^0.34.6",
81
81
  "cross-env": "^7.0.3",
82
- "eslint": "^8.51.0",
82
+ "eslint": "^8.52.0",
83
83
  "eslint-config-prettier": "^9.0.0",
84
- "eslint-plugin-jest": "^27.4.2",
84
+ "eslint-plugin-jest": "^27.6.0",
85
85
  "eslint-plugin-prettier": "^5.0.1",
86
86
  "eslint-plugin-react": "^7.33.2",
87
87
  "eslint-plugin-react-hooks": "^4.6.0",
88
88
  "eslint-plugin-storybook": "^0.6.15",
89
- "eslint-plugin-unicorn": "^48.0.1",
89
+ "eslint-plugin-unicorn": "^49.0.0",
90
90
  "jsdom": "^22.1.0",
91
91
  "prettier": "^3.0.3",
92
92
  "prop-types": "^15.8.1",
93
- "storybook": "^7.3.1",
93
+ "storybook": "^7.5.2",
94
94
  "typescript": "^5.2.2",
95
95
  "vitest": "^0.34.6"
96
96
  },